cat > T.C <<\EOF // { dg-do link } // { dg-options "-O0" } // { dg-additional-sources "T-aux.cc" }
#include "T.h" D::D (int x) : C (x) {} int main () { } EOF cat > T.h <<\EOF struct A { A (); ~A (); }; struct B { A b; virtual void mb (); B (int); virtual ~B (); }; struct C : public B { virtual void mc (); C (int); ~C (); }; inline C::~C () {} struct D : public C { A d; D (int); ~D (); }; EOF cat > T-aux.cc <<\EOF #include "T.h" A::A () {} A::~A () {} void B::mb () {} B::B (int) {} B::~B () {} void C::mc () {} C::C (int x) : B (x) {} D::~D () {} EOF g++ -o T T.c T-aux.cc fails on powerpc64-linux with: `C::~C()' referenced in section `.data.rel.ro._ZTV1C[vtable for C]' of /tmp/ccnVbxT3.o: defined in discarded section `_ZN1CD5Ev' of /tmp/ccnVbxT3.o While this doesn't fail to link on e.g. x86_64-linux, even there it is buggy: grep ZN1CD.*comdat T.s; echo $?; grep ZN1CD.*comdat T-aux.s .section.text._ZN1CD2Ev,"axG",@progbits,_ZN1CD5Ev,comdat 0 .section.text._ZN1CD2Ev,"axG",@progbits,_ZN1CD5Ev,comdat .section.text._ZN1CD0Ev,"axG",@progbits,_ZN1CD5Ev,comdat Deleting dtor wasn't emitted in T.s (no vtable is emitted there either). So I'm afraid we either need to add further restrictions on when we actually do optimize same body dtors (but have no idea at this point what that restriction would be, appart from disabling the optimization for virtual destructors, Jason, any ideas?), or would need to accept some bloat from time to time and change cgraph to force in also the deleting dtor if samebody complete/base dtor aliases are emitted in the D5 group. -- Summary: [4.5 Regression] Issues with comdat virtual dtors Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org GCC target triplet: powerpc64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42317