<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 10, 2014 at 1:02 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank">joerg@britannica.bec.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Fri, Jan 17, 2014 at 02:09:33AM -0000, Richard Smith wrote:<br>
> Author: rsmith<br>
> Date: Thu Jan 16 20:09:33 2014<br>
> New Revision: 199452<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199452&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=199452&view=rev</a><br>
> Log:<br>
> Issue a warning if a throwing operator new or operator new[] returns a null<br>
> pointer, since this invokes undefined behavior. Based on a patch by Artyom<br>
> Skrobov! Handling of dependent exception specifications and some additional<br>
> testcases by me.<br>
<br>
</div>OpenJDK contains code like<br>
<br>
void *foo::operator new(size_t, bar &, int, TRAPS) {<br>
if (error_condition)<br>
return 0;<br>
return some_value;<br>
}<br>
<br>
Should this warning really apply here?<br></blockquote><div><br></div><div>Yes, this is exactly the code that we wanted this warning to catch. If 'error_condition' is true, this code has undefined behavior.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Another issue is that it doesn't check whether the return statement is<br>
actually reachable, e.g. a __builtin_unreachable() just before it does<br>
not silence the warning. I think it should.</blockquote><div><br></div><div>Sure, if you want to go ahead and change the Diag to DiagRuntimeBehavior in CheckReturnValExpr, that seems fine to me. <br></div></div></div></div>