[cxx-abi-dev] Mangling sizeof

Jason Merrill jason at redhat.com
Thu Mar 5 19:12:08 UTC 2009


Jason Merrill wrote:
> template <int I> struct A { };
> template <class T> A<sizeof T(1)> f() { }
> int main()
> {
>   f<int>();
> }

I note that the EDG compiler I have doesn't even accept this testcase; 
it seems to be hitting a substitution failure and eliminating the 
template from overload resolution.  Which suggests that no code that 
currently compiles with the EDG front end would be affected by this change.

Incidentally, the somewhat related testcase

> template <typename T, T I = T()> struct A {};
> 
> template <typename T> void foo(A<T>) {}
> 
> void bar()
> {
>   foo(A<char>());
> }

gives

_Z3fooIcEv1AIT_XLi0EEE

with EDG, and an error about being unable to mangle T() with G++.  It 
seems that EDG is mangling A<T,T()> as A<T,0> rather than directly 
represent the conversion (which currently cannot be represented).

It occurs to me that constexpr will require direct representations of 
conversions with an arbitrary number of arguments, so we need to add 
that mangling regardless of the use of type stubs for decltype/sizeof.

Given that, the main thing that type stubs save us from needing to 
represent is new expressions, which cannot appear in a constant 
expression; other than that, they just save space in the mangled name.

Jason




More information about the cxx-abi-dev mailing list