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]

Bug with gcc-2.95.2 with -O causing link failure



Hi there,

 I assume that this is a bug (or I am misunderstanding something)

System:   RedHat7.0/x86
Compiler: Self compiled gcc-2.95.2
Linker:   GNU ld 2.10.90

This is a massively cut down program fragment from some of our source
code.

main.cc:
---------------------------------------------------------------------
struct A { virtual ~A() {} };

struct B {
        void foo() {
                struct C : public A {} xxx;
        }
};

int main() { return (0); }
---------------------------------------------------------------------

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/g++ -v
Reading specs from /usr/local/gcc-2.95.2-i686-pc-linux-gnu/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
%

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/g++ main.cc
%

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/g++ -O main.cc
/tmp/cc7g6aqn.o(.gnu.linkonce.d.__vt_Q31B9foo__1B.5_1C+0x8): undefined reference to `_._Q31B9foo__1B.1_1C.6'
collect2: ld returned 1 exit status
%

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/g++ -O -g main.cc
/tmp/ccgviu9O.o: In function `B::foo__1B.6::C type_info function':
/home/andrew/z/ld/2/main.cc:9: undefined reference to `_._Q31B9foo__1B.1_1C.6'
collect2: ld returned 1 exit status
%

Looking at the symbols in the .o file....

% nm --version
GNU nm 2.10.90
Copyright 1997, 98, 99, 2000 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/c++filt --version
GNU /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/c++filt (C++ demangler), version 2.95.2

% /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/g++ -O -c main.cc
% nm main.o | /usr/local/gcc-2.95.2-i686-pc-linux-gnu/bin/c++filt
         U _._Q31B9foo__1B.1_1C.6
00000000 ? __FRAME_BEGIN__
00000000 W __Q31B9foo__1B.2_1C.7
         U __rtti_si
         U __rtti_user
00000000 W B::foo__1B.6::C type_info function
         U __throw
00000008 C A type_info node
0000000c C B::foo__1B.0::C type_info node
00000000 V B::foo__1B.5::C virtual table
00000000 t gcc2_compiled.
00000000 T main

ie, it is right in saying that _._Q31B9foo__1B.1_1C.6 is undefined...

The same thing happens with egcs-1.1.2 (and also under Solaris2.6 with
both egcs-1.1.2 and gcc-2.95.2).

It does not happen with RedHat7.0's gcc-2.96.20000731. I haven't managed to
try the CVS head (or the gcc-3.0 branch...)

It also does not happen if there is not a virtual destructor on A.

Hopefully it is something simple (and maybe could be put into gcc-2.95.3?)

Thanks,
 Andrew.
--
 Andrew Pollard, ASI/Brooks Automation  | home: andrew@andypo.net
670 Eskdale Road, Winnersh Triangle, UK | work: Andrew_Pollard@autosim.com
 Tel/Fax:+44 (0) 118 9215603 / 9215660  | http://www.andypo.net


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