C++ demangler horrors
H. J. Lu
hjl@lucon.org
Fri Jun 27 05:50:00 GMT 2003
On Fri, Jun 27, 2003 at 03:33:20AM +0200, Oscar Fuentes wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
>
> > On Thu, Jun 26, 2003 at 10:25:24PM +0200, Oscar Fuentes wrote:
> >> Phil Edwards <phil@jaj.com> writes:
> >>
> >> > I very much doubt if this is going to happen, for three reasons:
> >> >
> >> > 1) Nobody will write a C++ replacement for vector and string. That's just
> >> > unnecessary reinvention of the wheel.
> >>
> >> Hi.
> >>
> >> Some time ago I was forced to write a vector & string replacement. It
> >> is not highly optimized, nor it has support for allocators, but I'm
> >> using it on a daily basis. The string is just a vector of chars plus
> >> the guarantee of a '\0' at the end.
> >>
> >> If you are interested, send me the *files* (not the patches, I'm not a
> >> gcc developer and I don't want to setup a build environment for it)
> >> and I'll see if I can make it work.
> >>
> >
> > Here is it is. Just untar and do
> >
> > # ./configure
> > # make
>
> Ok. The good news is that the demangler compiles with my vector/string
> replacement (dynstring is out as well) and produces the same output as
> the version you sent me.
>
> The bad news is that I can't figure out why the demangler is producing
> that output. Obviously I don't know how to use the demangler. My basic
> test is below.
>
> Please explain on how I must invoke the demangler to actually demangle
> the name.
>
> // File: main.cpp
> // compiled with g++ -static main.cpp -L./lib/.libs -ldemangler -liberty -o test
> // with gcc 3.3 on i386-unknown-netbsdelf1.6
>
> #include <stdlib.h>
> #include <stdio.h>
>
> extern "C" char*
> __cxa_demangle(char const* mangled_name, char* buf, size_t* n,
> int* status);
>
It is wrong. There should be no __cxa_demangle in demangle.o. Also you should
use "gcc", not "g++", when using -ldemangler. One thing you can try is check
out today's binutils from CVS, which has my new demangler testcases. You should
get many "make check" failures in libiberty. Then you replace cp-demangle.o
in libiberty.a with demangle.o and rebuild libiberty/testsuite/test-demangle.
You should get no "make check" failures in libiberty with the new libiberty.a.
H.J.
More information about the Gcc
mailing list