On Mon, Feb 10, 2014 at 1:02 PM, Joerg Sonnenberger <[email protected] > wrote:
> 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? > Yes, this is exactly the code that we wanted this warning to catch. If 'error_condition' is true, this code has undefined behavior. 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. Sure, if you want to go ahead and change the Diag to DiagRuntimeBehavior in CheckReturnValExpr, that seems fine to me.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
