This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [c++] Another question about demangler output
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 06 Dec 2003 21:08:49 -0500
- Subject: Re: [c++] Another question about demangler output
- References: <20031206235918.GA32439@nevyn.them.org>
Daniel Jacobowitz <drow@mvista.com> writes:
> Consider this program:
> template<typename B> class BB { public: BB() { }
> typedef int (*foot)(void);
> operator foot () { return 0; }
> };
>
> BB<int> obj;
>
> int foo()
> {
> return ((int (*)(void)) obj) != 0;
> }
>
> One symbol generated by this program is _ZN2BBIiEcvPFivEEv, which demangles
> as:
> BB<int>::operator int (*)()()
You don't need the template, of course. You can get your irritating
result with simply
class BB { typedef int (*foot)(void); operator foot (); };
BB::operator foot() { return 0; }
This gives _ZN2BBcvPFivEEv which (currently) demangles as
BB::operator int (*)()()
But using a gcc extension, I can do this without a typedef:
class BB { operator typeof (int(*)())(); };
BB::operator typeof (int(*)())() { return 0; }
So this suggests that the demangler should be changed. When a
conversion operator is used with a complex type, the demangler should
demangle the name using `typeof'.
Ian