------- Comment #28 from perry at kundert dot ca 2006-05-11 16:12 ------- This test case *still* exhibits the failure using only g++ 3.3.6, and binutils 2.16.1:
[EMAIL PROTECTED]:binutils-bug$ apt-show-versions g++-3.3 g++-3.3/testing uptodate 1:3.3.6-13 [EMAIL PROTECTED]:binutils-bug$ apt-show-versions binutils binutils/testing uptodate 2.16.1cvs20060413-1 [EMAIL PROTECTED]:binutils-bug$ cat GNUmakefile all: main clean: rm *.o lib1.o: lib1.C lib2.o: lib2.C main: main.C lib1.o lib2.o [EMAIL PROTECTED]:binutils-bug$ make clean all rm *.o g++ -c -o lib1.o lib1.C g++ -c -o lib2.o lib2.C g++ main.C lib1.o lib2.o -o main `.gnu.linkonce.t._ZN3Foo1fEi' referenced in section `.rodata' of lib2.o: defined in discarded section `.gnu.linkonce.t._ZN3Foo1fEi' of lib2.o collect2: ld returned 1 exit status make: *** [main] Error 1 [EMAIL PROTECTED]:binutils-bug$ (In reply to comment #27) > Here's a relatively simple test case, in case anyone wants one, that > reproduces > either this problem, or a very similar one. It requires a mix of compilers, > and of optimization selections, to reproduce, though. One gcc 3 compiler and > one gcc 4 one should do it. > > > $ cat foo.h > class Foo { > public: > virtual ~Foo() {} > virtual inline int f(int x) { > switch (x) { > case 0: return 0; break; > case 1: return 1; break; > case 2: return 2; break; // cases 0 to 2 bulk out the switch > statement > > case 3: return 999; break; // cases 3 and 4 can be coalesced > case 4: return 999; break; > } > return -1; > } > }; > > extern int g(int); > extern int h(); > > $ cat lib1.cc > #include "foo.h" > > int g(int i) { > Foo f; > return f.f(i); > } > > $ cat lib2.cc > #include "foo.h" > > int h() { > Foo f; > return f.f(0) + g(0); > } > > $ cat main.cc > #include "foo.h" > > int main() { > return g(0) + h(); > } > > $ ./g++-3.4.5 -Wall -W -pedantic -O2 -c lib1.cc > $ ./g++-3.4.5 -Wall -W -pedantic -O0 -c lib2.cc > $ ./g++-4.1.0 -Wall -W -pedantic -o main lib1.o lib2.o main.cc > /path/to/i686-unknown-linux-gnu/bin/ld: `.gnu.linkonce.t._ZN3Foo1fEi' > referenced in section `.rodata' of lib2.o: defined in discarded section > `.gnu.linkonce.t._ZN3Foo1fEi' of lib2.o > ... and so on > > In this case, the ld in gcc 4.1 is version 2.16.1. > -- perry at kundert dot ca changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |perry at kundert dot ca http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16625