What does MSVC think about:<div><br></div><div>void *operator new(unsigned int size, arbitrary_t);</div><div>void operator delete[](unsigned int size, arbitrary_t) = delete;</div><div>struct S { S(); };</div><div>S *p = new (arbitrary) S[5];<br>
<br>? Will it call the (deleted) operator delete[] even though it picked a non-array operator new?</div><div><br></div><div>What if there is an array new but no array delete?<br><br><div class="gmail_quote">On Tue, May 28, 2013 at 12:26 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">MSVC has a "neat trick" where it automatically falls back onto<br>
operator new when a placement operator new[] is called for which there<br>
is no valid declaration.  Eg)<br>
<br>
struct arbitrary_t {} arbitrary;<br>
void *operator new(unsigned int size, arbitrary_t);<br>
<br>
void f() {<br>
  int *p = new(arbitrary) int[4];<br>
  int *p2 = new(arbitrary) int;<br>
}<br>
<br>
MSVC will emit code to call operator new even though operator new[]<br>
does not exist.<br>
...<br>
push 16 ; 00000010H<br>
call ??2@YAPAXIUarbitrary_t@@@Z ; operator new<br>
...<br>
push 4<br>
call ??2@YAPAXIUarbitrary_t@@@Z ; operator new<br>
...<br>
<br>
This patch emulates the MSVC behavior when compiling in<br>
ms-compatibility mode and tests both the semantic requirements as well<br>
as the codegen requirements.  It addresses PR13164, which points out<br>
that this is holding back usage for the WDK because it does not<br>
implement the array version of nothrow'ing new.<br>
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>