__cxa_demangle of type manglings

Jason Merrill jason at redhat.com
Mon Jan 10 18:54:48 UTC 2005


Between gcc 3.2 and 3.4, our demangler was rewritten.  The ABI
specification says that the argument to __cxa_demangle can be 'either an
external name, i.e. with a "_Z" prefix, or an internal NTBS mangling,
e.g. of a type for type_info', and later that

'Ambiguities are possible between extern "C" object names and internal
built-in type names, e.g. "i" may be either an object named "i" or the
built-in "int" type. Such ambiguities should be resolved to user names over
built-in names.'

Our old implementation ignored this rule, and preferred the type
interpretation.  The new one still prefers the type interpretation for
compound types such as PPv (void**), but returns "invalid mangled name" for
built-in type names, which is clearly a bug.

It seems to me that the specified behavior makes __cxa_demangle useless for
type manglings, since most of them are also valid C++ identifiers, and
therefore could be an extern "C" object name.  I think that the ambiguity
should be resolved the other way by default, and that we should add another
way to specify that the argument is an external name, probably via another
entry point.

Jason



More information about the cxx-abi-dev mailing list