analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle
Ian Lance Taylor
ian@wasabisystems.com
Tue Feb 24 01:18:00 GMT 2004
Benjamin Kosnik <bkoz@redhat.com> writes:
> FAIL: demangle/regression/cw-11.cc execution test
> string: _X11TransParseAddress
> libiberty: _X11TransParseAddress, -2: invalid mangled name
> libstdc++: _X11TransParseAddress
>
> Same: this is twisted, but not invalid.
Hmmm. I'm not really sure what the issue is here. That is not a
valid mangled name. So my version of the function returns failure
with a status of -2. What is it supposed to return?
The ABI says ``The return value is a pointer to a null-terminated
array of characters, the demangled name.'' And it says that for an
error in demangling, -2 means an ``invalid mangled name.'' And the
mangled-name argument is required to be ``either an external name,
i.e. with a "_Z" prefix, or an internal NTBS mangling, e.g. of a type
for type_info.''
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?
Note that it necessarily matters, but I note that my interpretation is
the same as the historical cplus_demangle() interface in libiberty;
when given a name which can not be interpreted as a mangled name, it
returns NULL.
Ian
More information about the Libstdc++
mailing list