C++ Logo

std-proposals

Advanced search

Re: [std-proposals] It seems impossible to use new on a class with a deleted operator delete

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 21 Sep 2024 11:01:10 -0700
On Saturday 21 September 2024 10:35:31 GMT-7 Julian Waters via Std-Proposals
wrote:
> is this intended or an oversight?

It's needed. As you noticed, the compiler is required to free the memory it
allocated on new if the constructor throws.

And like in other conditions, it doesn't matter if the constructor in question
is noexcept. The operator delete must be callable as must all the destructors
of the sub-objects.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-09-21 18:01:22