[cxx-abi-dev] Possibly ambiguous mangling of extern "C" functions
Dennis Handly
dhandly at cup.hp.com
Wed Aug 20 02:37:48 UTC 2008
>From: Michael Wong <michaelw at ca.ibm.com>
>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.
extern "C" bool IsEmpty(char*); // (un)mangled as IsEmpty
template<bool (&)(char*)> struct CB { static int x; };
int *p = &CB<IsEmpty>::x;
>which may be OK if the group decides it is so since extern "C"
>function can't be overloaded anyway and you can't have it with different
>parameters. But then why bother to mangle it at all?
Mangle IsEmpty as a parm? You have to put something there.
>Checking various versions of GNU also shows different mangling with the
>_ZN2CBILZ7IsEmptyEE1xE extern "C"
>_ZN2CBILZ7IsEmptyPcEE1xE extern "C++"
These don't demangle with GNU c++filt 2.17.
>_ZN2CBIXL7IsEmptyEEE1xE extern "C"
>_ZN2CBIXL_Z7IsEmptyPcEEE1xE extern "C++"
Only the last demangles with GNU c++filt 2.17.
>Anybody can report what EDG/Intel generates?
Michael Wong
Raw EDG gives: _ZN2CBIXL_Z7IsEmptyEEE1xE
With strict mode EDG and the default aCC6, it doesn't seem to like it at all:
error #2434: a reference of type "bool (&)(char*)" (not const-qualified)
cannot be initialized with a value of type "bool (char*) C"
That "C" means extern "C".
So it appears EDG says your example is illegal?
Perhaps because it is reusing a function for initialization for template
arg validation??
To get this to work, I have to use a typedef:
#ifdef WORK
extern "C" {
typedef bool (&RBF)(char*);
}
template<RBF> struct CB { static int x; };
#else
template<bool (&)(char*)> struct CB { static int x; };
#endif
And this gives: _ZN2CBIXL_Z7IsEmptyEEE1xE
More information about the cxx-abi-dev
mailing list