PR C++/88114 - patch for destructor not generated for "virtual ~destructor() = default"
Tobias Burnus
tobias.burnus@physik.fu-berlin.de
Fri Jan 11 18:36:00 GMT 2019
Dear Jason, dear all,
Jason Merrill wrote on 5 Dec 2018:
> You can get at the destructor with CLASSTYPE_DESTRUCTOR rather than walking through TYPE_FIELDS. I'd also check DECL_DEFAULTED_IN_CLASS_P.
> I'd also do this in maybe_emit_vtables rather than here, so that it only happens once per class.
Updated patch. I also added a test case which checks that the destructor
is not generated.
[ Original patch: https://gcc.gnu.org/ml/gcc-patches/2018-11/msg01824.html ]
Background again:
If a class contains any 'virtual ... = 0', it's an abstract class and for an
abstract class, the destructor not added to the vtable.
For a normal
virtual ~class() { }
that's not a problem as the class::~class() destructor will be generated during
the parsing of the function.
But for
virtual ~class() = default;
the destructor will be generated via mark_used via the vtable.
If one now declares a derived class and uses it, the class::~class() is generated
in that translation unit. Unless, #pragma interface/implementation is used.
In that case, the 'default' destructor will never be generated.
Build and regtested on x86_64-gnu-linux.
OK? Or do you have more suggested changes?
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr88114-destructor-default-v2.diff
Type: text/x-diff
Size: 3190 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190111/56918c3a/attachment.bin>
More information about the Gcc-patches
mailing list