[cxx-abi-dev] Mangling sizeof

Jason Merrill jason at redhat.com
Wed Mar 11 17:45:11 UTC 2009


Doug Gregor wrote:
> On Wed, Mar 11, 2009 at 9:25 AM, Jason Merrill <jason at redhat.com> wrote:
>> So [different casts] really should all be mangled differently, though
>> C-style and functional casts can stay the same.  But that's a binary
>> incompatibility that should probably wait until we're ready to deploy a
>> bunch of binary-incompatible changes.
> 
> Do casts within mangled sizeof()s actually work well in any compiler?
> If not, then we might have more wiggle-room to fix this sooner rather
> than later.

Casts can appear outside of sizeof(), and I don't feel comfortable 
guessing that nobody is using *_cast that way.  Though as I think I 
already mentioned, there's some incompatibility between compilers with 
that already:

template <class T, T t = static_cast<T>(0)>
struct A { };

template <class T>
A<T> f(T t) { return A<T>(); }

int main()
{
   f(42);
}

gives
_Z1fIiE1AIT_XLi0EEES1_ with EDG (12/08/2008),
_Z1fIiE1AIT_XcvS1_Li0EEES1_ with G++.
i.e. EDG drops the conversion entirely.  Changing the type of 't' to int 
and the argument to f to char, I get

_Z1fIcE1AIT_XcviLi0EEES1_ with EDG,
_Z1fIcE1AIT_XcvS1_Li0EEES1_ with G++.
Here EDG represents the conversion, but it's to the wrong type.

Jason



More information about the cxx-abi-dev mailing list