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

Jason Merrill jason at redhat.com
Wed Jan 4 19:04:07 UTC 2012


And then similarly,

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

void g()
{
   A<char,B::cmp1> a;
   B::f(a);
   A<char,B::cmp2> a2;
   B::f(a2);
}

Should the cmp1 in the first f be mangled as simply 4cmp1 or should it 
include B::?  That is,

_ZN1B1fIcEEvR1AIT_X4cmp1EE (which Clang produces)
or
_ZN1B1fIcEEvR1AIT_XsrS_4cmp1EE

?  I could go either way, but it seems that we've been leaning toward 
mangling expressions as written, which would suggest the former.

I think the second f should be

_ZN1B1fIcEEvR1AIT_L_ZNS_4cmp2EccEE

Jason



More information about the cxx-abi-dev mailing list