https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68210
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Or maybe: int main () { void *p = operator new (1, std::nothrow); VERIFY (p != 0); VERIFY (1 == new_called); VERIFY (0 == new_handler_called); VERIFY (!bad_alloc_thrown); operator delete(p); new_fail = true; p = operator new (1, std::nothrow); VERIFY (0 == p); VERIFY (2 == new_called); VERIFY (0 == new_handler_called); VERIFY (bad_alloc_thrown); new_fail = true; bad_alloc_thrown = false; std::set_new_handler (new_handler); p = operator new (1, std::nothrow); VERIFY (0 == p); VERIFY (3 == new_called); VERIFY (2 == new_handler_called); VERIFY (!bad_alloc_thrown); }