g++ -v: Using built-in specs. Target: i686-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux Thread model: posix gcc version 4.4.3 20100127 (Red Hat 4.4.3-4) (GCC) Command line used to compile the example program: g++ -o main main.cpp For some template types the output of abi::__cxa_demangle is incorrect. This was working OK in version 4.3.0 Example program is attached Expected output (when compiled with gcc version 4.3.0 20080428 (Red Hat 4.3.0-8)): Mangled name: N5boost6tuples5tupleIN5abcde5xyzzz3abc4abcd3AaaENS5_4klmn16BaaaaaaaaaaaaaaaENS0_9null_typeES9_S9_S9_S9_S9_S9_S9_EE Demangled name: boost::tuples::tuple<abcde::xyzzz::abc::abcd::Aaa, abcde::xyzzz::abc::abcd::klmn::Baaaaaaaaaaaaaaa, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> Actual output (when compiled with gcc version 4.4.3 20100127 (Red Hat 4.4.3-4)): Mangled name: N5boost6tuples5tupleIN5abcde5xyzzz3abc4abcd3AaaENS5_4klmn16BaaaaaaaaaaaaaaaENS0_9null_typeES9_S9_S9_S9_S9_S9_S9_EE Demangled name: boost::tuples::tuple<abcde::xyzzz::abc::abcd::Aaa, abcde::xyzzz::abc::abcd::klmn::Baaaaaaaaaaaaaaa, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_ty> As you can see the last occurrence of "null_type" gets truncated to "null_ty". The mangled name is the same for both compiler versions. Note that after making some of the namespace or class names shorter the output is correct.
Created attachment 20456 [details] Preprocessed source of example program
Can you please provide a shorter, self-contained (no includes), testcase? Thanks in advance. CC-ing Ian...
Created attachment 20869 [details] simpler example Preprocessed source of simpler program. The only #include used was <typeinfo> which is needed in order to compile with g++
Excellent, thanks a lot.
I also double checked that indeed the last "null_type" appears truncated.
Ian, any idea what may be happening here?
Non pre-processed testcase. Apparently some buffer is overflowed. #include <cxxabi.h> namespace abcdefgxyzzzaaaaabbbbbb { class Aaa { }; namespace klmn { class Baaaaaaaaaaaaaaa { }; } } namespace boost { namespace tuples { class null_type; template<typename T1 = null_type, typename T2 = null_type, typename T3 = null_type, typename T4 = null_type, typename T5 = null_type, typename T6 = null_type, typename T7 = null_type, typename T8 = null_type, typename T9 = null_type, typename T10 = null_type> struct tuple { }; } } int main() { int status = 0; const char* mangled_name = typeid(boost::tuples::tuple<abcdefgxyzzzaaaaabbbbbb::Aaa, abcdefgxyzzzaaaaabbbbbb::klmn::Baaaaaaaaaaaaaaa>).name(); __builtin_printf("Mangled name:\n%s\n\n", mangled_name); const char* dem_name = abi::__cxa_demangle(mangled_name, 0, 0, &status); if (0 == status) __builtin_printf("Demangled name:\n\n%s\n\n", dem_name); return 0; }
Recategorizing as other (like 42230)... and maybe HJ is interested in playing a bit with this one too.
It is caused by revision 142799: http://gcc.gnu.org/ml/gcc-cvs/2008-12/msg00498.html
Thanks HJ.
Can be reproduced also with c++filt _ZN5boost6tuples5tupleIN23abcdefgxyzzzaaaaabbbbbb3AaaENS2_4klmn16BaaaaaaaaaaaaaaaENS0_9null_typeES6_S6_S6_S6_S6_S6_S6_EE
I see the bug.
Subject: Bug 43838 Author: jakub Date: Thu Jun 10 15:15:18 2010 New Revision: 160554 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160554 Log: PR other/43838 * cp-demangle.c (struct d_print_info): Add flush_count field. (d_print_init): Initialize it to 0. (d_print_flush): Increment it. (d_print_comp): If needed flush before appending ", ". Only decrement dpi->len if no flushes happened during the recursive call. * testsuite/demangle-expected: Add a test for this. Modified: trunk/libiberty/ChangeLog trunk/libiberty/cp-demangle.c trunk/libiberty/testsuite/demangle-expected
Subject: Bug 43838 Author: jakub Date: Thu Jun 10 15:24:11 2010 New Revision: 160555 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160555 Log: PR other/43838 * cp-demangle.c (struct d_print_info): Add flush_count field. (d_print_init): Initialize it to 0. (d_print_flush): Increment it. (d_print_comp): If needed flush before appending ", ". Only decrement dpi->len if no flushes happened during the recursive call. * testsuite/demangle-expected: Add a test for this. Modified: branches/gcc-4_5-branch/libiberty/ChangeLog branches/gcc-4_5-branch/libiberty/cp-demangle.c branches/gcc-4_5-branch/libiberty/testsuite/demangle-expected
Subject: Bug 43838 Author: jakub Date: Thu Jun 10 15:31:56 2010 New Revision: 160556 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160556 Log: PR other/43838 * cp-demangle.c (struct d_print_info): Add flush_count field. (d_print_init): Initialize it to 0. (d_print_flush): Increment it. (d_print_comp): If needed flush before appending ", ". Only decrement dpi->len if no flushes happened during the recursive call. * testsuite/demangle-expected: Add a test for this. 2009-06-16 Nick Clifton <nickc@redhat.com> PR 10197 * testsuite/test-demangle.c: Rename getline to get_line to avoid conflicts with system function of the same name. Modified: branches/gcc-4_4-branch/libiberty/ChangeLog branches/gcc-4_4-branch/libiberty/cp-demangle.c branches/gcc-4_4-branch/libiberty/testsuite/demangle-expected branches/gcc-4_4-branch/libiberty/testsuite/test-demangle.c
Fixed.