[Bug c++/17182] New: [3.5 regression] virtual destructor not in shared library
Ralf dot Wildenhues at gmx dot de
gcc-bugzilla@gcc.gnu.org
Wed Aug 25 13:07:00 GMT 2004
This example fails on CVS HEAD gcc (as of yesterday), but not 3.4, neither does
the original problem from which I stripped this example fail with CVS from 6
weeks ago.
/* Save this as a.cc
g++ -fPIC -DPIC -c -o a.o a.cc
g++ -shared a.o -o libfoo.so
Now, link a trivial program against it (int main(void) { }).
g++ -o b b.cc -L. -lfoo
*/
struct B {
virtual ~B () { }
virtual void dummy() { }
};
void bar()
{
struct C : public B {
C (const B& b) : B(b) { }
};
B b;
new C(b);
}
The error given is
./libfoo.so: undefined reference to `bar()::C::~C()'
./libfoo.so: undefined reference to `bar()::C::~C()'
with current gcc.
BTW, the 'new C(b);' line is not necessary with CVS HEAD to expose the bug.
With 3.4, however, class C is optimized away completely without this line.
Regards,
Ralf
--
Summary: [3.5 regression] virtual destructor not in shared
library
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Ralf dot Wildenhues at gmx dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17182
More information about the Gcc-bugs
mailing list