[Bug libstdc++/68210] nothrow operator fails to call default new
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 10 19:35:00 GMT 2018
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);
}
More information about the Gcc-bugs
mailing list