Skip to content

Operator new and -fno-exceptions #60129

Closed
@asl

Description

@asl

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?

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++abilibc++abi C++ Runtime Library. Not libc++.quality-of-implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions