[llvm-dev] PVS-Studio analysis of LLVM code

Nathan Froyd via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 3 12:38:56 PDT 2016


On Wed, Nov 2, 2016 at 9:41 AM, Jonas Wagner via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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?

For the record, we did not replace `new` with `new (std::nothrow)`.
We define our own versions of global `operator new` such that it
crashes the program on OOM (via abort(3) or moral equivalent) rather
than attempting to throw an exception.  (There are, as you might
imagine, many hoops to jump through to do this.)  We do have
non-crashy versions (the moral equivalents of `new (std::nothrow)`),
of course, but the majority of the codebase uses the crashy `operator
new`.

Having PVS tell us where we aren't supposed to be checking for `new`
failure would be really useful: we made `new` infallible a while back,
but there's still a fair amount of code that unnecessarily checks for
`new` returning nullptr...

-Nathan


More information about the llvm-dev mailing list