[cxx-abi-dev] Mangling of function-to-pointer conversion

Jason Merrill jason at redhat.com
Fri Mar 4 17:17:24 UTC 2011


A related case:

template<typename T> int cmp1(T a, T b);
template<typename T> int cmp2(T a, T b);
template<typename T, int (*cmp)(T, T)> struct A { };
template <typename T> void f (A<T,cmp1> &);
void g()
{
   A<char,cmp1> a;
   f(a);
}

How do we mangle 'cmp1' in the signature of f?  The ABI doesn't say 
anything specific about how to mangle unresolved overloading.

G++ currently crashes on this testcase, but some obvious fixes lead it 
to generate "4cmp1", i.e. <unresolved-name>, which seems consistent with 
the mangling in a dependent call.

EDG 4.2 mangles it as adL_Z4cmp1, which doesn't seem to match anything 
in the spec; it seems to be treating the cmp1 template as an extern "C" 
function.  I tried to create an analogous dependent call to see what it 
would do in that case:

template <class T, int I> struct B { };
template <class T> void h(B<T,sizeof(cmp1(T(),T()))>);

void i()
{
   B<int,sizeof(int)> b;
   h(b);
}

but EDG 4.2 rejects this testcase.

Jason



More information about the cxx-abi-dev mailing list