Is constructor called if nothrow new return nullptr?

279 views Asked by At

If I use new and get std::bad_alloc compiler do not call constructor because of exception. But how does it works with the nothrow new cause we get pointer in every case? Is there special paragraph in standard for this case?

1

There are 1 answers

0
Igor Tandetnik On BEST ANSWER

[expr.new]/16 ... if the allocation function returns null, initialization shall not be done, the deallocation function shall not be called, and the value of the new-expression shall be null.