This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [c++] Another question about demangler output


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]