<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 2, 2016 at 9:41 AM, Jonas Wagner via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think this should be added by Clang itself.</blockquote><div><br></div></span><div>I don't think so. There are several sources online that indicate that developers need to <i>manually</i> specify std::nothrow. If they don't, operator new will throw an exception even if code is compiled with -fno-exception. This will abort the program.</div></div></div></blockquote><div><br></div><div>That's correct. The default new should never return nullptr, even with -fno-exceptions. It should either succeed, throw an exception, or abort.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>At some point, this caused Firefox to replace a bunch of `new` with `new(std::nothrow)` [1] Would this be a good idea in LLVM as well? Or should we just let LLVM crash on OOM, and remove the null-checks as PVS suggests?</div></div></div></blockquote><div><br></div><div>LLVM shouldn't replace new with new(std::nothrow), it should just abort. There's effectively zero chance the codebase will ever be able to recover from OOMing, and with modern OSes, you're almost never going to actually see a malloc failure until it's way too late, anyways.</div></div></div></div>