Mangling late-specified return types/decltype

Jason Merrill jason at redhat.com
Fri Sep 5 21:11:45 UTC 2008


Doug Gregor wrote:
> This seems like an odd choice to me. Is it okay that these two will
> have the same mangling:
> 
>   template<typename T> void f(T x, T y) -> decltype(x + y) { } // #1
>   template<typename T> void f(T x, T y) -> decltype(x + x) { } // #2
> 
> while these two, which also have the same return type, have different manglings?
> 
>   template<typename T> void f(T&& x, T& y) -> decltype(x + y) { } // #3
>   template<typename T> void f(T&& x, T& y) -> decltype(x + x) { } // #4
 >
> The return types are the same because parameters whose type is an
> rvalue reference are treated as lvalues, so "x" and "y" behave the
> same way from the point of view of the type system. However, we're
> mangling x and y differently because they have different declared
> types.
> 
> It seems like we either want #1 and #2 to have different manglings (by
> making references to function parameters like we do with template
> parameters) or we want #3 and #4 to have the same mangling (e.g., by
> using the type of the expression with an lvalue or rvalue marker).

I would expect 1/2 and 3/4 to have the same mangling.  That is, the 
placeholder would have the type of the parameter when used in an 
expression (T), not a reference type.

Jason




More information about the cxx-abi-dev mailing list