https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111854

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> You are mixing up 2 different things.
> First this is about if the operator new is valid and it is because there is
> a corresponding placement delete operator (this would be rejected at compile
> time).

The point is that [expr.new] p28 says it's ill-formed. Yes, there's a
corresponding delete operator, but it's one of the "usual deallocation
functions", and that isn't an allowed lookup result for a placement new
expression.

This might seem surprising, but it's what the standard says.

> Second is if you can call the normal delete on an allocated memory from that
> inplacement new call. The answer is yes you can and not invoke undefined
> behavior.

That's not what the standard says.

'delete p' will call either operator delete(void*) or operator delete(void*,
size_t), and those functions have a precondition that the pointer was obtained
from an allocation function without an alignment parameter. See
[new.delete.single] p11.

Reply via email to