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

Mike Herrick mjh at edg.com
Fri Jan 6 21:44:23 UTC 2012


On Jan 5, 2012, at 9:53 PM, John McCall wrote:

> On Jan 4, 2012, at 10:22 AM, Jason Merrill wrote:
>> On 01/04/2012 11:42 AM, Mike Herrick wrote:
>>>> template<typename T>  int cmp1(T a, T b);
>>>> int cmp2(char a, char b);
>>>> template<typename T, int (*cmp)(T, T)> struct A { };
>>>> template<typename T>  void f (A<T,cmp1> &);
>>>> template<typename T>  void f (A<T,cmp2> &);
>>>> void g()
>>>> {
>>>> A<char,cmp1>  a;
>>>> f(a);
>>>> A<char,cmp2>  a2;
>>>> f(a2);
>>>> }
>>>> 
>>> We agree that <unresolved-name> is the way to go here.
>> 
>> For the first f<char>, or both?  For the two f<char>, I think we should produce
>> 
>> _Z1fIcEvR1AIT_X4cmp1EE
>> _Z1fIcEvR1AIT_L_Z4cmp2ccEE
>> 
>> Do you agree?
> 
> I agree with this.

Agreed.

How about this case (explicit "B::" added):

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

I'm assuming that the first "f" should now be _ZN1B1fIcEEvR1AIT_XsrS_4cmp1EE and the second "f" is unchanged (i.e., _ZN1B1fIcEEvR1AIT_L_ZNS_4cmp2EccEE).

Mike Herrick
Edison Design Group




More information about the cxx-abi-dev mailing list