https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94355
William Navarre <navarre.gcc.bugs at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |navarre.gcc.bugs at gmail dot com --- Comment #8 from William Navarre <navarre.gcc.bugs at gmail dot com> --- It seems that `operator new` is generally not supposed to return NULL -- std::bad_alloc() is supposed to be thrown instead. I made that change on my build (see below). I think that treating new's result as never-null is probably the correct thing to do most of the time, but two considerations: 1) The case of allocating a zero-length array. 2) The case that a project has replaced `operator new.` (See "global replacements" at https://en.cppreference.com/w/cpp/memory/new/operator_new). Apparently projects can replace `operator new` (see "global replacements" at https://en.cppreference.com/w/cpp/memory/new/operator_new). It's not clear --- a/gcc-11.1.0/gcc/analyzer/sm-malloc.cc +++ b/gcc-11.1.0.navarre/gcc/analyzer/sm-malloc.cc @@ -1527,9 +1527,9 @@ malloc_state_machine::on_stmt (sm_context *sm_ctxt, } if (is_named_call_p (callee_fndecl, "operator new", call, 1)) - on_allocator_call (sm_ctxt, call, &m_scalar_delete); + on_allocator_call (sm_ctxt, call, &m_scalar_delete, true); else if (is_named_call_p (callee_fndecl, "operator new []", call, 1)) - on_allocator_call (sm_ctxt, call, &m_vector_delete); + on_allocator_call (sm_ctxt, call, &m_vector_delete, true); else if (is_named_call_p (callee_fndecl, "operator delete", call, 1) || is_named_call_p (callee_fndecl, "operator delete", call, 2)) {