Compile this code, reduced from gdb.cp/templates.cc: === char name[3]; template<char *V> struct Qux { int foo(); };
template<char *V> int Qux<V>::foo() { return V[0]; } Qux<name> qux; === Look at the resulting debug information, by building with -c -g and using readelf -wi, or by compiling with -S -dA. Take a look at the type of the instantiated foo. G++ calls it Qux<(char*)(& name)>::foo(). But that's not right. For the first thing, I believe it's not valid C++. G++ certainly rejects the obvious ways of writing this. But worse is that it is representable in the mangling. The actual method: _ZN3QuxIXadL_Z4nameEEE3fooEv -> Qux<&(name)>::foo() But this is validly mangled: _ZN3QuxIXcvPcadL_Z4nameEEE3fooEv -> Qux<(char*)(&(name))>::foo() There are tons of other places where GCC emits debug info different from the demangler, usually in spacing or in the spelling of basic types (long unsigned int vs unsigned long); I have code in GDB to correct for all such cosmetic differences but I am reluctant to make it remove casts that could be important. -- Summary: Debugging info for C++ template parameters is incorrect Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: drow at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33861