r199452 - Issue a warning if a throwing operator new or operator new[] returns a null
Joerg Sonnenberger
joerg at britannica.bec.de
Mon Feb 10 13:02:34 PST 2014
On Fri, Jan 17, 2014 at 02:09:33AM -0000, Richard Smith wrote:
> Author: rsmith
> Date: Thu Jan 16 20:09:33 2014
> New Revision: 199452
>
> URL: http://llvm.org/viewvc/llvm-project?rev=199452&view=rev
> Log:
> Issue a warning if a throwing operator new or operator new[] returns a null
> pointer, since this invokes undefined behavior. Based on a patch by Artyom
> Skrobov! Handling of dependent exception specifications and some additional
> testcases by me.
OpenJDK contains code like
void *foo::operator new(size_t, bar &, int, TRAPS) {
if (error_condition)
return 0;
return some_value;
}
Should this warning really apply here?
Another issue is that it doesn't check whether the return statement is
actually reachable, e.g. a __builtin_unreachable() just before it does
not silence the warning. I think it should.
Joerg
More information about the cfe-commits
mailing list