Subject: Re: [std-proposals] Make abstract classes non-deletable if no virtual destructor available
From: Ryan Nicholl (rnicholl_at_[hidden])
Date: 2020-03-23 15:25:18
Is there any possibility that working code could do this in unreachable paths? Maybe using templates? I don't think it'd be very common in any case. At least a warning should be required by the standard on the next version, and make it an error the version after?
-------- Original Message --------
On Mar 23, 2020, 16:19, Kilian Henneberger via Std-Proposals wrote:
> an abstract class (a class that either defines or inherits at least one
> function for which the final overrider is pure virtual)
> cannot be instantiated. However it can be destroyed. But deleting a
> Derived-object through a pointer to Base-object
> leads to undefined behaviour if the destructor of the Base-class is not
> There also exists a CppCoreGuideline addressing this topic:
> I want to propose that we make the attempt to delete a pointer to an
> abstract class ill-formed,
> if the abstract class does not have a (public) virtual destructor.
> This would turn what currently is UB into a compiler error.
> But it also might imply that code which compiles today (even if leading
> to UB), wont compile any longer after this change.
> I am looking forward to any feedback.
> Best regards,
> Kilian Henneberger
> Std-Proposals mailing list
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups