<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Aug 1, 2013, at 12:19 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com">Paul_Robinson@playstation.sony.com</a>> wrote:<br><div><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Suppose a class Foo has a user-supplied operator new, that can return null.<br>The standard permits this behavior if operator new is marked as 'noexcept'<br>or 'throw()'.<br><br>If operator new cannot throw, then when we 'new Foo' and the operator<br>returns null, Clang generates code to detect that case and skips calling<br>the object constructor.<br><br>Now suppose operator new is NOT marked 'noexcept' but instead we compile<br>the program with -fno-exceptions; it turns out that Clang treats this<span class="Apple-converted-space"> </span><br>operator new as if it could throw--that is, it will not detect the null<br>return value and calls the constructor with a null 'this' pointer (with<br>predictable consequences). Shouldn't this case be equivalent to marking<br>our operator new with 'noexcept', and check for the null return value?<br></div></blockquote><div><br></div></div>No. The basic design of -fno-exceptions is “the user promises there are<div>never any exceptions being thrown”; it does not mean exactly the same as</div><div>putting a noexcept specification on every function and call. If null is a valid</div><div>result of your operator new, put a noexcept specification on it.</div><div><div><br></div><div>John.</div></div></body></html>