Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ref-qualifier on "this" and mangling

39 views
Skip to first unread message

Marc

unread,
Apr 20, 2012, 4:58:45 AM4/20/12
to
Hello,

while the question appears to be about a specific ABI, it is really
about the validity of code that would expose issues in it.

Starting from a member function type and applying the following trait,
one can get a function type:

template<class> struct RP;
template<class T,class F> struct RP<T F::*>{typedef T type;};

If the member function has a cv-qualifier (that applies to *this), it
gives a strange type like int(double)const. In name mangling terms,
this can be encoded by taking the type int(double) and making it
const, and since a function cannot be const it is unambiguous.

Now in C++11, we can also have ref-qualifiers on *this, so it seems
natural to proceed in the same way. Except that this time,
int(&)(double) is a valid type, completely unrelated to int(double)&.
Clang mangles them the same (and so will probably all other users of
the Itanium C++ ABI), which seems to me to be an issue, but it is
quite possible that the contorsions necessary to make the type
int(double)& appear are illegal, although DR 1417 seems to confirm
what I say.

Any opinion?


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

wasti...@gmx.net

unread,
Apr 20, 2012, 10:11:50 AM4/20/12
to
On Friday, April 20, 2012 10:58:45 AM UTC+2, Marc wrote:
> Now in C++11, we can also have ref-qualifiers on *this, so it seems
> natural to proceed in the same way. Except that this time,
> int(&)(double) is a valid type, completely unrelated to
> int(double)&. Clang mangles them the same (and so will probably all
> other users of the Itanium C++ ABI), which seems to me to be an
> issue, but it is quite possible that the contorsions necessary to
> make the type int(double)& appear are illegal, although DR 1417
> seems to confirm what I say.
>
> Any opinion?

Looks like an oversight in the Itanium ABI to me.

Sebastian
0 new messages