[cxx-abi-dev] Possibly ambiguous mangling of extern "C" functions

David Vandevoorde daveed at edg.com
Tue Aug 19 23:17:02 UTC 2008


On Aug 19, 2008, at 9:12 AM, Michael Wong wrote:

> The example in question is at the end of "5.1.5 Type encodings".  of
> http://www.codesourcery.com/public/cxx-abi/abi.html.
>
> In this example, it is using an extern "C" function as a parameter  
> to a
> class template. There are two problems:
> 1. Should there be full mangling, partial mangling, or no mangling  
> of the
> extern 'C" function as a template parameter?
> 2. Should there be an X...E (after the I and before the L) since  
> there is
> a <expr-primary> production under <template-arg> that makes that the  
> case.
>
> Here is the example I actually used:
>
> extern "C" bool IsEmpty(char *); // (un)mangled as IsEmpty
> template<bool (&)(char *)> struct CB { static int x; };
> // CB<IsEmpty> is mangled as "2CBIL_Z7IsEmptyEE"
> int *p = &CB<IsEmpty>::x;


Normally, we issue the following error on that example:

"t.c", line 4: error: a reference of type "bool (&)(char *)" (not
           const-qualified) cannot be initialized with a value of type
           "bool (char *) C"
   int *p = &CB<IsEmpty>::x;
                ^

which I think is right.

When I enable the emulation of GCC, we accept it and mangle it as  
_ZN2CBIXL_Z7IsEmptyEEE1xE.

We also have a mode to emulate what we consider "GNU ABI bugs".  When  
I enable that, we generate _ZN2CBIXL7IsEmptyEEE1xE.

	Daveed




More information about the cxx-abi-dev mailing list