[Bug c++/58678] [4.9 Regression] pykde4-4.11.2 link error (devirtualization too trigger happy)

trippels at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 27 21:40:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58678

--- Comment #58 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
A gentoo user wrote me that pykde still fails with the same error
when build with -flto. 
And indeed both the testcase from comment0 and from comment 13 still
fail with -flto:

markus@x4 /tmp % cat test.ii
class A {
 public:
    virtual ~A();
};
class B : A {
    virtual int m_fn1();
};
void fn1() {
    delete reinterpret_cast<B*>(1);
}

markus@x4 /tmp % cat test2.ii
class Part {
public:
  virtual ~Part();
};
class A : Part {};
void fn1() {
  A *a;
  delete a;
}

markus@x4 /tmp % g++ -Wl,--no-undefined -shared -fPIC -flto -O2 test.ii
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function B::~B(): error:
undefined reference to 'vtable for B'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld:
the vtable symbol may be undefined because the class is missing its key
function
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function B::~B(): error:
undefined reference to 'A::~A()'
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function B::~B(): error:
undefined reference to 'vtable for B'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld:
the vtable symbol may be undefined because the class is missing its key
function
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function fn1(): error:
undefined reference to 'vtable for B'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld:
the vtable symbol may be undefined because the class is missing its key
function
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function fn1(): error:
undefined reference to 'A::~A()'
/tmp/ccvkKVlc.ltrans0.ltrans.o:ccvkKVlc.ltrans0.o:function B::~B(): error:
undefined reference to 'A::~A()'
collect2: error: ld returned 1 exit status

markus@x4 /tmp % g++ -Wl,--no-undefined -shared -fPIC -flto -O2 test2.ii
/tmp/ccY0KXU2.ltrans0.ltrans.o:ccY0KXU2.ltrans0.o:function A::~A(): error:
undefined reference to 'Part::~Part()'
/tmp/ccY0KXU2.ltrans0.ltrans.o:ccY0KXU2.ltrans0.o:function A::~A(): error:
undefined reference to 'Part::~Part()'
/tmp/ccY0KXU2.ltrans0.ltrans.o:ccY0KXU2.ltrans0.o:typeinfo for A: error:
undefined reference to 'typeinfo for Part'
collect2: error: ld returned 1 exit status

markus@x4 /tmp % g++ -Wl,--no-undefined -shared -fPIC -O2 test.ii
markus@x4 /tmp % g++ -Wl,--no-undefined -shared -fPIC -O2 test2.ii
markus@x4 /tmp %



More information about the Gcc-bugs mailing list