http://sourceware.org/bugzilla/show_bug.cgi?id=12762
Summary: lto produces multiple definition errors for virtual function Product: binutils Version: 2.22 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassig...@sources.redhat.com ReportedBy: vanboxem.ru...@gmail.com I don't know if this is a GCC or ld bug, but as the error happens in the link stage, I'm posting it here. To reproduce: class.h ------- class A { public: virtual ~A() {} }; class B : public A { public: ~B() {} }; class.cpp --------- #include "class.h" // just make sure there's more than one object file main.cpp #include "class.h" int main() { B b; return 0; } Compile with "g++ -flto" from the 4.6 branch and link with "g++ -flto" which invokes ld and collect2. Produced errors: release/class.o (symbol from plugin):(.text+0x0): multiple definition of `typeinfo for A' release/main.o (symbol from plugin):(.text+0x0): first defined here release/class.o (symbol from plugin):(.text+0x0): multiple definition of `typeinfo name for A' release/main.o (symbol from plugin):(.text+0x0): first defined here release/class.o (symbol from plugin):(.text+0x0): multiple definition of `typeinfo for B' release/main.o (symbol from plugin):(.text+0x0): first defined here release/class.o (symbol from plugin):(.text+0x0): multiple definition of `typeinfo name for B' release/main.o (symbol from plugin):(.text+0x0): first defined here collect2: ld returned 1 exit status Please note that compiling Qmake (when configuring Qt) or a larger C++ project with -flto produces multiple definitions of stuff like std::allocator operator new and other standard C++ stuff. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils