analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle

Ian Lance Taylor ian@wasabisystems.com
Tue Feb 24 01:43:00 GMT 2004


Mark Mitchell <mark@codesourcery.com> writes:

> Ian Lance Taylor wrote:
> 
> > So by my reading, when given something like _X11TransParseAddress
> > which is not a valid mangled name, it is correct for __cxa_demangle()
> > to return NULL with status set to -2.
> > What other reading could there be?
> 
> The ABI implies that you can feed an 'extern "C"' name to __cxa_demangle.
> 
> For example, it says that "i" should be demangled as "i".
> 
> It's hard (for me) to see how to get that without considering "i" a
> valid mangled name.

That turns out not to be the case.  The ABI says that an ambiguity
between an extern "C" name and an internal built-in type name should
be resolved in favor of the extern "C" name.  It doesn't say what to
return for an extern "C" name.  That is, it doesn't say that
__cxa_demangle() should return "i" when passed "i".

In fact, I'm just writing the disambiguation code now in my demangler,
and my natural inclination is to write it so that when
__cxa_demangle() is passed "i", it returns NULL with *status set to
-2.

Ian



More information about the Libstdc++ mailing list