This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: mark at codesourcery dot com, libstdc++ at gcc dot gnu dot org
- Date: 23 Feb 2004 20:18:49 -0500
- Subject: Re: analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle
- References: <20040223170416.7a0ab854.bkoz@redhat.com>
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