Linking fails with
b.o:b.cpp:(.text$_ZN4TestC1Ev[Test::Test()]+0x8): undefined reference to `vtable
for Test'
if object file is stored in an archive but succeeds if not.

Reproducible with this testcase:
### a.h ###
class Test
{
public:
        virtual void do_something();
};
### a.cpp ###
#include "a.h"

void Test::do_something()
{
}
### b.cpp ###
#include "a.h"
int main( int argc, char** argv )
{
        Test test;
        
        return 0;
}
### build object files "a.o" "b.o" and put "a.o" in archive "a.a"
g++ -c -o a.o a.cpp && g++.exe -c -o b.o b.cpp && ar -q a.a a.o
### linking with object files succeeds
g++ -o c a.o b.o
### linking with archive file fails
g++ -o c a.a b.o


nm shows for the archive a.a and for the object a.o the same symbols. So it
should succeed.

-- 
           Summary: undefined reference vtable if symbol is in archive
           Product: binutils
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: binutils dot scyt at spamgourmet dot com
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


http://sourceware.org/bugzilla/show_bug.cgi?id=2478

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to