[cxx-abi-dev] Decltype mangling and type dependency

David Vandevoorde daveed at edg.com
Thu Oct 28 15:33:50 UTC 2010


On Oct 25, 2010, at 10:35 AM, Michael Wong wrote:

> 
> Hi all, so does anyone know which way this mangling will become? Will it
> just use the DT/Dt codes or be collapsed. If we have two ways then it
> clearly will not be binary compatible.
> We have also noted the following similar case which seems to be
> inconsistent.
> struct A
> {
>             struct B
>             {
>             } b;
> }a;
> 
> template <class X> auto fn1(X x)->decltype(x) {}
> template <class X> auto fn2(X x)->decltype(x) {}
> template <class X> auto fn3(X x)->decltype(x.b) {}
> template <class X> auto fn4(X &x)->decltype(x) {}
> 
> int main()
> {
>  fn1(100);		 //_Z3fn1IiET_                  <-- decltype is folded away
> (should it be preserved?)

Actually, that doesn't look like a folded return type, but an altogether removed return type, no?

With the proposed new rules this becomes  _Z3fn1IiEDtfp_ET_, I believe.


>  fn2(a);                      //_Z3fn2I1AET_                      <--
> decltype is folded away (should it be preserved?)


Similarly, I don't see the encoded return type there.  I think it will become _Z3fn2I1AEDtfp_ET_.


>  fn3(a);                      //_Z3fn3I1AEDtdtfp_1bET_

That's already fine, I think.

>  fn4(a);                //_Z3fn4I1AEDtfp_

I suspect that one suffered a cut-n-paste error: The Dt is unterminated, and the parameter type is absent.

I expect the encoding _Z3fn4I1AEDtfp_ERT_.


> }
> 
> In these special cases, what is the rationale behind folding away decltype
> mangling for dependent types?
> As a follow-up, are there special cases where decltype mangling is
> preserved for: decltype expressions with non-dependent types,
> value-dependent decltype expressions?

Yes, see the last proposed patch (I pinged Mark to integrate it).  E.g., something like decltype(sizeof(T)) results in a nondependent type when it's valid, but since it can be invalid (e.g., T = void) it must be encoded explicitly.

	Daveed






More information about the cxx-abi-dev mailing list