<div dir="ltr">I forgot to say that &quot;behaves right&quot; requires operator new to correspond to operator delete.<br><br>If it corresponds, then the behavior is completely correct, because the delete expression is equivalent to call destructor + operator delete.<div><br></div><div>Of course the code could be better:<br><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">auto* p = operator new(sizeof(T));<br>auto* pc = new(p) T;<br>::delete pc;<br><br></blockquote>This way for any T, the code is correct.<br><div><br></div><div>If T definitely does not overload operator new and operator delete, then :: may not be used. If it&#39;s wrong, the behavior is undefined.</div></div><div><br></div><div>The same applies to the original issue.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 2, 2022 at 9:29 AM Jason McKesson via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, Oct 1, 2022 at 8:51 PM blacktea hamburger via Std-Proposals<br>
&lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt; wrote:<br>
&gt;<br>
&gt; I&#39;m using &quot;forbid&quot; wrong. It should be &quot;undefined behavior,&quot; because obviously it can&#39;t be checked at compile time. It&#39;s better to make it well-formed, because unintended but correct behavior is better than undefined behavior.<br>
<br>
That changes nothing about my question: why not? Equally importantly,<br>
how is it &quot;correct behavior&quot;? It&#39;s code that is *incoherent.* You<br>
initialized the object in a way that says something about the<br>
relationship between the object and its storage, and you destroyed the<br>
object in a way that says something *different* about the relationship<br>
between the object and its storage.<br>
<br>
Why is this &quot;correct behavior&quot;? Who is to say what &quot;correct behavior&quot;<br>
even is if you&#39;re not consistent on what you&#39;re doing?<br>
<br>
Not to mention the fact that, as Thiago pointed out, it is not even<br>
&quot;correct behavior&quot; if `T` has an `operator delete` overload. And<br>
again, IOC can work just fine on such types.<br>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div>

