Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A mangling ambiguity


  • To: cxx-abi-dev@xxxxxxxxxxxxxxxx
  • Subject: A mangling ambiguity
  • From: "J. Stephen Adamczyk" <jsa@xxxxxxx>
  • Date: Tue, 3 Dec 2002 14:25:59 -0500 (EST)

Here's an interesting case that shows an ambiguity problem with name
mangling:

template <class T> struct A {
  template <class U> operator U() { return 0; }
};
int main() {
  A<float> a;
  int i = a;
}

The mangled name for the conversion function is

_ZN1AIfEcvT_IiEEv
            ^problem here

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, however, and it happily
takes the template argument list as part of the type, presumably in
this case as a template argument list for a template template parameter.
This is illustrated by what the g++ demangler does with this name:

A<float>::operator float<int>()

This seems like a genuine ambiguity.  Or does someone see an out I'm
missing?

Steve Adamczyk
Edison Design Group