This is the mail archive of the gcc-bugs@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]

PCH bug? - symbol mangling


I believe I may have found a bug with the new PCH code.  It's easy to 
duplicate with two files:


----- test.h
#include <iostream>
----- end test.h

----- test.cc
#include "test.h"
int main()
{
    std::cout << "Hi!" << std::endl;
}
----- end test.c


Without using PCH: "g++34 -c test.cc ; nm test.o" yields

----- (without PCH)
00000096 t _GLOBAL__D_main
0000007a t _GLOBAL__I_main
         U __gxx_personality_v0
00000000 T main
0000003c t _Z41__static_initialization_and_destruction_0ii
         U _ZNSolsEPFRSoS_E
         U _ZNSt8ios_base4InitC1Ev
         U _ZNSt8ios_base4InitD1Ev
         U _ZSt4cout
         U _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
00000000 b _ZSt8__ioinit
         U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
----- end (without PCH)

Using PCH: "g++34 test.h ; g++34 -c test.cc ; nm test.o" yields

----- (with PCH)
00000096 t _GLOBAL__D_main
0000007a t _GLOBAL__I_main
         U __gxx_personality_v0
00000000 T main
0000003c t _Z41__static_initialization_and_destruction_0ii
         U _ZNSt13basic_ostreamIcSt11char_traitsIcEElsEPFRS2_S3_E
         U _ZNSt8ios_base4InitC1Ev
         U _ZNSt8ios_base4InitD1Ev
         U _ZSt4cout
         U _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
00000000 b _ZSt8__ioinit
         U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
----- end (with PCH)

The only difference is the lines

without PCH: U _ZNSolsEPFRSoS_E
with PCH:    U _ZNSt13basic_ostreamIcSt11char_traitsIcEElsEPFRS2_S3_E

These both demangle to more or less the same thing of course - the type 
for the endl manipulator - but libstdc++ defines only the former, so 
linking the latter version of test.o fails!

----- linker output
test.o: In function `main':
test.o(.text+0x30): undefined reference to `std::basic_ostream<char, 
std::char_traits<char> >::operator<<(std::basic_ostream<char, 
std::char_traits<char> >& (*)(std::basic_ostream<char, 
std::char_traits<char> >&))'
----- end linker output

Any idea why using PCH results in the "So" abbreviation not being used for 
ostream?  I'm on Intel Linux here... I'll be happy to file a bug report 
if necessary.

- Jon


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