Issue with vtable duplication when compiling c++

Nick Burrett nick at sqrt.co.uk
Fri Aug 13 03:30:44 PDT 2004


John-Mark Bell wrote:

> During compilation of a number of C++ sources with GCCSDK 3.3 or 3.4 (CVS 
> head), I've noticed that in certain circumstances the vtable for a class 
> gets duplicated, thus causing a link error.
> 
> I've produced a minimal test case which exhibits this behaviour, which is 
> attached to this email, with any luck. It can also be downloaded from  
> http://www.ecs.soton.ac.uk/~jmb202/riscos/g++test.zip
> 
> This testcase compiles (and links) correctly with the 32bit 2.95.4 on 
> Peter Naulls' site. It also compiles correctly with gcc 3.3.3 for x86 and  
> gcc3.2 for arm-linux (although I expect this information isn't 
> particularly useful ;)

The problem here is to do with linker sections.  x86 g++ 3.3 does 
duplicate the vtable block in both object files, however it uses a 
gnu_linkonce attribute and section names to ensure that the linker 
doesn't give multiple definitions.


Nick.




More information about the gcc mailing list