we get duplicate underscore prefixes on std::string template function calls generated when using -fleading-underscore the .stabs entries are fine ("_ZNSs7reserveEm") but the generated assembler code calls "__ZNSs7reserveEm" with two underscores instead so the linker gives us a undefined symbol "__ZNSs7reserveEm" error we tried with -O2, -O1, and -O0 and get the same result other templates compile fine ------------------------------ Using built-in specs. Target: i386-unknown-elf Configured with: ../configure --with-mpfr-dir=../../mpfr-2.2.1/ --target=i386-unknown-elf --prefix=/home/shockenhull/bin/i386-unknown-elf --enable-targets=all Thread model: single gcc version 4.1.1 Linux shockenhull 2.6.16.13-4-smp #1 SMP Wed May 3 04:53:23 UTC 2006 i686 athlon i386 GNU/Linux ------------------------------------------- i386-unknown-elf-g++ -c -fleading-underscore -g -O0 -D__cpluscplus -D__CYGWIN__ -I../externals/include/w32api -D__cdecl= -Ddllimport= -DDECLSPEC_NORETURN= --save-temps -DTARGET_WIN32 -DTARGET_OS="WIN32" -DPRAY_WINDOWS_DOESNT_CRASH=1 -DTARGET_IA32 -DTARGET_CPU="IA32" -D__cdecl= -D__declspec= -Ddllimport= -D__INSIDE_CYGWIN__ -Wno-pmf-conversions -I../ -I../../../ -I/home/shockenhull/projects/sqrlen/base -I/home/shockenhull/projects/sqrlen/base/win32 -I/home/shockenhull/projects/sqrlen/base/ia32 -I../externals/include -I../../../src -I/home/shockenhull/projects/sqrlen/drivers/video_out -I/home/shockenhull/projects/sqrlen/drivers/video_out/win32_gl_hack -I/home/shockenhull/projects/sqrlen/drivers/pc_misc/xml -I/home/shockenhull/projects/sqrlen/drivers/pc_misc/ministring -I/home/shockenhull/projects/sqrlen/drivers/fs -I/home/shockenhull/projects/sqrlen/drivers/fs/win32 -include windef.h -o pc_misc/xml/test.o /home/shockenhull/projects/sqrlen/drivers/pc_misc/xml/test.cpp ----------------------------------------------------------- #include <stdio.h> #include <string> void bob(void) { std::string s; s = "biby"; s.replace(1, 4, "ob"); printf("%s\n", s.c_str()); } ----------------------------------------------------------- I have the the test.ii file but it is 424KiB so I cannot post it here. please email me for the file, I will email it back.
Created attachment 14598 [details] .ii file that produce error
this bug seem to be related to the fact that std::string's name mangling is optimized by shortening it to a special encoding which might bypass the underscore prefix option is there an option to disable the special case encoding for std::string ?
the problem is in the pre-compiled c++ library work around: using option -D_GLIBCXX_EXTERN_TEMPLATE=0 disable pre-compiled templates in the c++ headers and force correct instanciation when -fleading-underscore is used thanks to Andrew Pinski for pointing to the "extern template" feature. maybe overriding the platform's defaut underscore prefix should define _GLIBCXX_EXTERN_TEMPLATE=0 if not overriden explicitly so the glitch wont come up?
This is not a bug since you did not compile libstdc++ with -fleading-underscore. There are some headers with extern template.