[cxx-abi-dev] Possibly ambiguous mangling of extern "C" functions
John H. Spicer
jhs at edg.com
Wed Aug 20 12:45:36 UTC 2008
On Aug 20, 2008, at 4:19 AM, Mark Mitchell wrote:
> David Vandevoorde wrote:
>
>>> 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"
>
> Yes, that's the right error. G++ has never implemented extern "C"
> function *types*, so doesn't issue this kind of error. There are
> extern "C" functions, but the linkage isn't part of the type per
> se. This is a known bug.
>
> So, now we're talking about mangling for an invalid C++ program,
> which is outside the scope of the ABI.
There is a well-formed varient of this case though:
extern "C" {
bool IsEmpty(char *); // (un)mangled as IsEmpty
typedef bool (&ref_func)(char *);
}
template<ref_func> struct CB { static int x; };
int *p = &CB<IsEmpty>::x;
John Spicer
Edison Design Group
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20080820/6edc8468/attachment.html>
More information about the cxx-abi-dev
mailing list