<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60129>60129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Operator new and -fno-exceptions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
question,
libc++,
libc++abi,
quality-of-implementation
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
asl
</td>
</tr>
</table>
<pre>
Current implementation of `operator new` in libcxx / libcxxabi effectively makes plain `new` and nothrow `new` to coincide when exceptions are disabled: both will return nullptr. However, there is one important difference: for nothrow `new` the constructor is not called when the return value is null. This does not happen for ordinary `new` in `-fno-exceptions` case making impossible to check the return value as constructor might just segfault. From the user perspective it might be better to stick to one of the following:
* Just call `abort()`. This seems what is currently done for things like `std::__throw_out_of_range` in `-fno-except` case
* Make `operator new` and nothrow `operator new` to behave identically and do not call constructor
Any thoughts on what might be the better solution?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxslE-PozgQxT-NuZQSGZN_HDhkphWtVlrtZe-RbQrsaWMzdrnT-fYrQ7Yn071SlETgqvferwpkSnb0iB3bf2P7l0pmMiF2MrlKhf7efc8xoiew0-xwQk-SbPAQBmAHHmaMkkIEjzd24GA9OKv0-zswcXn8lcoCDgNqsm_o7jDJV0wwO2l9afGolL4HH8jEcHu6SgF0sF7bHuFm0AO-a5yLgQQyIvQ2SeWwZ80ZVCADN-scRKQcPfjs3ExxC3-EG75hZOI7kMGIYBMEjyVSiCQ9QW-HASN6jaXTUAJ99WIQdPCJYtYlsk3lEGjpHParu3LkIf4mXV6Eiost_GNsgj7gWmPkPKNfdELsrZfx_iS0ctkMPmx-xS03tExY8Fk_Lt5TssrhAsmgfv0qL9Nvjic7GoIfOREkHAeZHW3hEsO0VOaEEWaMaV5HBZYeFQpBIRHGIpXIFqmwEAzDUjoE58LN-pE1Z8ZfGD8DMHGGP4tUAVQCSRUiMXFiomUH_kCSEKcENyOpsNLrrrk79KV74UPG-jGBs69YmiQqs2bN-Xpd5nMNma5huEbpR_xfeP-Be_b1l1y7fV7fT0v4-TYFUGhkQdOjJ1uS3ZeiPnzswjPxVXP9Pvs7kAl5NFS2b838wbdQfDBOweUyctZcqr5r-rZpZYVdfTju-JE3B16Zrlb7naiHVtWHejjqWh9P8tjujlLUpxZbXtlOcNHwuj7VbSN2fKv4nitUqjntudzrnu04TtK6rXNv0zbEsbIpZewOvBZt5aRCl5ZXghA_M6bFkBBMfGdClOeaiW_L58slqezH1Z9ZOkv3TRg2v78-yon9SxW7or5ReUxsx51NlH75IUsOu7-fZrCg_vRcVDm6zhDNqeyFuDBxGS2ZrLY6TExcSrvHz2aO4QdqYuKyZE1MXJa4_wYAAP__Nq6yHQ">