[cxx-abi-dev] A mangling ambiguity

J. Stephen Adamczyk jsa at edg.com
Sat Dec 7 11:52:02 UTC 2002


Martin von Loewis writes:
> > At the indicated point, the result type of the conversion function ("T_")
> > should end, and the template argument list that follows ("IiE") should
> > apply to the conversion function itself, not to its return type.
> > There's no way for a demangler to know that
> 
> Why not? If this were a template argument to the conversion-type-id,
> there would have to be another template argument list, which specifies
> the conversion operator's template arguments,

The return type of the conversion function might or might not
take a template argument list, and the conversion function itself
might or might not take an template argument list (it takes a
template argument list if it's a member template).

I haven't been able to come up with an example where two different
functions produce the same mangled name, but the demangling ambiguity
is there for sure.

Here are two examples:

template <class T> struct Z {};
template <class T, template <class U> class TT> struct A {
  operator TT<T>();
};
int main() {
  A<int, Z> a;
  Z<int> x = a;
}


template <class T> struct Z {};
template <class T, template <class U> class TT> struct A {
  template <class T> operator T();
};
int main() {
  A<int, Z> a;
  int x = a;
}

First  mangled name is _ZN1AIi1ZEcvS0_IiEEv
Second mangled name is _ZN1AIi1ZEcvT_IiEEv

These are syntactically identical, but the template argument in one
case is related to the return type, and in the other case it's related
to the conversion function template.

Steve Adamczyk
Edison Design Group



More information about the cxx-abi-dev mailing list