Mangling ambiguity

Alain Miniussi alainm at cup.hp.com
Fri Apr 28 21:00:28 UTC 2000


Daveed Vandevoorde wrote:
> 
> Matt Austern wrote:
> [...]
> >        template <class T> struct A { };
> >        template <class T> struct B { };
> >
> >        template <class T> struct X        { void f(T); };
> >        template <class T> struct X<A<T> > { void f(T); };
> >
> > Now consider how to mangle these instantiations:
> >     void X<A<int> >::f(int);
> >     void X<B<int> >::f(B<int> >);
> >
> > Under our current rules, I claim that the latter is clearly
> >     _Z N 1X I1BIiEE 1f E vT1_
> >
> > How about the former?  It depends on how "multiple levels of template"
> > is to be interpreted, and we could reasonably interpret it as saying
> > either that the mangling should be
> >     _Z N 1X I1AIiEE 1f E vT1_
> > or that it should be
> >     _Z N 1X I1AIiEE 1f E vT2_
> >
> > We should clarify the rules to make sure we say that it's "T2_"
> > instead of "T1_", because otherwise we'll have an ambiguity that can
> > be resolved only by the demangler knowing whether or not it's dealing
> > with a partial specialization.
> 
> I must be going blank, but where is the ambiguity with the first
> mangling? 

Let's start with:
template <class T> struct X { void f(T); };

we want to encode X<A<int> >::void f(T):
_Z N 1X I1AIiEE 1f E vT1_

Here, that mangled name seems to refer to void X<%1>::f(%1) with
%1=A<int>
Now, if we also consider:

template <class T> struct X<A<T> > { void f(T); };

and consider that 1 is the number of the first and only parameter T, we
have(for the same mangling):

void X<A<%1>::f(%1) with %1=int

And we don't know, while demangling, if we have a specialization.
So the idea is to say that we want to consider an occurence 
(probably the first but it's not explictly said yet) of T in the
actual instantiation parameters:

Instead of considering things like this:
template<class T:1> struct X<A<T> > { void f(%1); }

consider:
template<class T> struct X<A:1<int:2> > { void f(%2); }

Note that I think that the most general case must take into 
account that T can appears different time ( X<C<T,T> >) and 
that we need to put a number on every subtype  
(X<int*> -> X<int:2*:1>).

Alain


> In the latter case, what does "T2_" refer to given that
> there is only one template parameter?
> 
>         Daveed




More information about the cxx-abi-dev mailing list