Problem mangling template template parameters
nasgaard at ca.ibm.com
nasgaard at ca.ibm.com
Thu Dec 19 21:24:27 UTC 2002
We have noticed a problem in with the way g++ mangles template functions
that have template template parameters. Here's an example:
struct bus{};
template < class T,int I > struct A
{
typedef bus X;
};
template<class T> struct A<T,3>
{
typedef char X;
};
template <template <class B,int I> class XX> void foo(typename XX<int,3>::X a){}
template <template <class B,int I> class XX> void foo(typename XX<int,4>::X a){}
int main()
{
struct bus test;
foo<A>('x');
foo<A>(test);
}
g++ mangles both function template names the same, _Z3fooI1AEvN2XX1XE. It appears that the template parameters are not mangled as part of the name.
I would like to verify what we believe the correct mangling should be. If we take the first instantiation of foo I think the correct name should be
_Z3fooI1AEvN2XXIiLi3EE1XE.
The productions followed to get this would be (starting with the parameter type):
<type> ::= <class-enum-type>
<class-enum-type> ::= <name>
<name> ::= <nested-name>
<nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
<prefix> ::= <template-prefix> <template-args>
<template-prefix> ::= <prefix> <template unqualified-name>
<prefix> ::= <prefix> <unqualified-name>
<prefix> ::= empty
<unqualified-name> ::= <source-name>
<source-name> ::= XX
<template-args> ::= I <template-arg>+ E
<template-arg> ::= <type>
<type> ::= <cv-qualifiers> <type>
<type> ::= i
<template-arg> ::= L <type> <value number> E
<type> ::= i
<value number> ::= 3
<unqualified-name> ::= <source-name>
<source-name> ::= X
Can you verify that this is correct. Is this what will be implemented in g++ v3.3?
Howard W. Nasgaard
C++ Compiler Development
e-mail: nasgaard at ca.ibm.com
C2/KD2/8200/MKM
905-413-3683
Tie: 969-3683
More information about the cxx-abi-dev
mailing list