[cxx-abi-dev] N4198 and mangling for member pointer template arguments
Richard Smith
richardsmith at google.com
Wed Nov 26 02:13:53 UTC 2014
N4198 (accepted at Urbana) makes it possible for a template parameter of
type T U::* to have a template argument of type T V::*, where V is a base
class of U or vice versa. A naive attempt to apply the existing ABI rules
leads to mangling collisions in cases like this:
struct A { int n; };
struct B : A {};
template<int A::*> void f() {}
template<int B::*> void f() {}
void g() {
constexpr int A::*p = &A::n;
constexpr int B::*q = p;
f<p>();
f<q>();
}
(Here, a naive approach would use XadL_ZN1A1nEEE as the template argument
value in both calls.)
In order to resolve this, I suggest we introduce a new mangling for the
case of a member pointer template argument where the class containing the
member is different from the class in the template parameter. The minimal
information we'll need to include is the class in the template parameter
and a designator if the base class is a repeated base class.
One approach would be to use
sc <type> ad L<member>E
and to explicitly include the final type plus those intermediate types that
introduce multiple inheritance from the base class (that is, just enough to
uniquely identify the path).
Another would be to introduce a new mangling that incorporates the final
type and an offset or discriminator.
Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20141125/11b89186/attachment.html>
More information about the cxx-abi-dev
mailing list