[Bug c++/37677] New: GCC produces mangled names which can't be demangled

2008-09-29 Thread meheff at gcc dot gnu dot org
The following code produces a bad mangled name (or at least a mangled name that
c++filt cannot handle):

template  class C { public: C(); };
class D
{
public:
 template 
 operator C() { return C(); }
};
C foo(D* p) { return *p; }

The final line produces the symbol ZN1Dcv1CIT_EIbEEv.  c++filt cannot demangle
it.

Below is


-- 
   Summary: GCC produces mangled names which can't be demangled
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: meheff at gcc dot gnu dot org
 GCC build triplet: i686-unknown-linux
  GCC host triplet: i686-unknown-linux
GCC target triplet: i686-unknown-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37677



[Bug c++/37677] GCC produces mangled names which can't be demangled

2008-09-29 Thread meheff at gcc dot gnu dot org


--- Comment #1 from meheff at gcc dot gnu dot org  2008-09-30 00:10 ---
(In reply to comment #0)
> The following code produces a bad mangled name (or at least a mangled name 
> that
> c++filt cannot handle):
> 
> template  class C { public: C(); };
> class D
> {
> public:
>  template 
>  operator C() { return C(); }
> };
> C foo(D* p) { return *p; }
> 
> The final line produces the symbol ZN1Dcv1CIT_EIbEEv.  c++filt cannot demangle
> it.
> 
> Below is
> 

Grrr... sent too soon.  Below is a side channel email from [EMAIL PROTECTED]
about the problem:

This produces the symbol _ZN1Dcv1CIT_EIbEEv which is not demangled.
Building the demangler code with -DSTANDALONE_DEMANGLER
-DCP_DEMANGLE_DEBUG gives me this:

> ./foo _ZN1Dcv1CIT_EIbEEv
typed name
 template
   qualified name
 name 'D'
 cast
   template
 name 'C'
 template argument list
   template parameter 0
   template argument list
 builtin type bool
 function type
Failed: _ZN1Dcv1CIT_EIbEEv

This works out to something like
   (D::operator C)()
It's weird because there seems to be an extra templatization in
there.  The symbol is really
   D::operator C()
which has one template.  So why does the mangled name have two?

Clearly the "T_" is expected to map to "b".  If I do that mapping
myself (_ZN1Dcv1CIbEIbEEv) it demangles to
   D::operator C()
which is weird.

I'm inclined to think that the correct mangling for this should be
_ZN1Dcv1CIbEEv, which demangles to simply
   D::operator C()
I don't understand the extra level of template wrapping.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37677