Issue with vtable duplication when compiling c++

John-Mark Bell jmb202 at ecs.soton.ac.uk
Sat Aug 21 01:55:50 PDT 2004


On Mon, 16 Aug 2004, Nick Burrett wrote:

> 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.
> 
> A fix has now been committed to the 3.4 release for this.  It changes 
> the C++ ABI slightly and will therefore require a complete rebuild of 
> GCC and all C++ object files.
> 
> Hopefully the change hasn't introduced any side effects, but I cannot be 
> 100% sure at this time.

Many thanks for this. Unfortunately, it fails to link in certain 
circumstances. 
For example, the following (trivial and rather pointless) source:

#include <iostream>
#include <sstream>
#include <string>

std::string foo(void)
{
  std::ostringstream res;

  res << "Foo";

  return res.str();
}

int main(void)
{
  std::cout << foo();
  return 0;
}

produces these errors:

Error: Size of common area 'C$$.gnu.linkonce.t._ZNSdD0Ev' in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
io-inst.o' differs from definition in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
sstream-inst.o' (360 != 134867856)
Error: Size of common area 'C$$.gnu.linkonce.t._ZNSdD1Ev' in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
io-inst.o' differs from definition in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
sstream-inst.o' (352 != 134868048)
Error: Size of common area 'C$$.gnu.linkonce.t._ZNSdD2Ev' in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
io-inst.o' differs from definition in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
sstream-inst.o' (308 != 134869648)
Error: Size of common area 'C$$.gnu.linkonce.t._ZNSdD0Ev' in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
fstream-inst.o' differs from definition in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
sstream-inst.o' (360 != 134867856)
Error: Size of common area 'C$$.gnu.linkonce.t._ZNSdD1Ev' in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
fstream-inst.o' differs from definition in 
'/home/jmb/gcc34/arm-riscos-aof/gcc-3_4/libstdc/stage2/apcs32/arch3/unixlib/
sstream-inst.o' (352 != 134868048)
Drlink: Link failed with 5 errors

This is with a completely clean checkout of CVS head. Any thoughts?

Cheers,

John.




More information about the gcc mailing list