<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 25, 2014 at 11:21 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">>>! In D4774#11, @samsonov wrote:<span style="color:rgb(34,34,34)">>>! In D4774#10, @rsmith wrote:</span><br>
</div></div><div class="">
> Is this change correct? Suppose I do this:<br>
><br>
>     char Buffer[32];<br>
>     // ...<br>
>     new (Buffer) int[4];<br>
>     // ...<br>
>     new (Buffer) int(0);<br>
><br>
> Won't we get a false positive on the last line?<br>
<br>
</div>Not sure  I understand this test.<br>
First, with arrays of PODs you don't have  cookies at all.<br>
Second, do we have the cookie with placement new at all?<br></blockquote><div><br></div><div>Good point. Here's a complete test case:</div><div><br></div><div><div>  void *operator new[](unsigned long, char *);</div>
<div>  struct S { S(); ~S(); int n; };</div><div>  char Buffer[20];</div><div>  S *p = new (Buffer) S[20];</div><div>  int main() { return Buffer[0]; }</div></div><div><br></div><div>I think it's fine to activate the sanitizer for new-expressions that call the usual (replaceable) global array new, since in that case the program really can't use those bytes, and the only way to free them is with a 'delete[]' expression. But I don't think you can do this for a placement array new.</div>
<div><br></div><div>(The good news is that placement array new's are not widely used and are mostly useless so we don't lose much by adding this restriction.)</div></div></div></div>