Mangling late-specified return types/decltype
Doug Gregor
doug.gregor at gmail.com
Fri Sep 5 21:21:46 UTC 2008
On Fri, Sep 5, 2008 at 5:11 PM, Jason Merrill <jason at redhat.com> wrote:
> 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.
I didn't realize we were stripping reference types. In that case, it's
fine. Thanks for the clarification.
- Doug
More information about the cxx-abi-dev
mailing list