[cxx-abi-dev] Possibly ambiguous mangling of extern "C" functions
Michael Wong
michaelw at ca.ibm.com
Tue Aug 26 21:31:19 UTC 2008
Thanks all for the discussion. This case was taken pretty much from the C++
ABI spec.
So it sounds like the spec is OK, in that a valid variant of the case as
Dennis Handly and John Spicer shown below, should be mangled as:
_ZN2CBIL_Z7IsEmptyEE1xE
SO we have:
1. GCC 4.1.2 is in error by missing the _
2. the rest of us are in error by adding the X ...E
Michael Wong
XL C++ Compiler kernel Development
IBM Canada Ltd., C2/KD2/8200/MKM
8200 Warden Avenue
Markham, Ontario L6G 1C7
W:905-413-3283 F:905-413-4839
Boost test results
http://www-1.ibm.com/support/docview.wss?rs=2239&context=SSJT9L&uid=swg27006911
C/C++ Compilers Support Page
http://www.ibm.com/software/awdtools/ccompilers/support/
C/C++ Feature Request Interface
http://www.ibm.com/support/docview.wss?uid=swg27005811
XL Fortran Compiler Support Page
http://www.ibm.com/software/awdtools/fortran/xlfortran/support/
XL Fortran Feature Request Interface
http://www.ibm.com/support/docview.wss?uid=swg27005812
Re: [cxx-abi-dev] Possibly ambiguous mangling of extern "C" functions
John H. Spicer
to:
Mark Mitchell
08/20/2008 09:11 AM
Cc:
David Vandevoorde, Michael Wong, cxx-abi-dev
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/20080826/e42c077c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20080826/e42c077c/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic31992.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20080826/e42c077c/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20080826/e42c077c/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1E899343.gif
Type: image/gif
Size: 821 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20080826/e42c077c/attachment-0003.gif>
More information about the cxx-abi-dev
mailing list