https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64535
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Richard Biener from comment #11) > If reading 15.1.4 (Exception Handling / Throwing an exception) correctly > then allocation happens in an unspecified way but according to 3.7.3.1 > which specifies that if "the allocation function" that fails to allocate > storage shall throw std::bad_alloc (if not marked with throw ()). But > it isn't specified if the "unspecified" EH allocation "function" is > marked with throw (). An "allocation function" specifically refers to an overload of operator new. The reference from 15.1.4 [except.throw] to [basic.stc.dynamic.allocation] is apparently meant to refer to the final paragraph, which says: "[ Note: In particular, a global allocation function is not called to allocate storage for [...] an exception object (15.1). — end note ]" so it's saying that operator new must not be used to allocate memory for exceptions (but it's OK to use malloc or a static buffer or both). That means the rules for how operator new indicates OOM are not relevant for exception handling. > In particular 15.5.1 (The std::terminate function) doesn't list OOM > in allocating an exception as cause of abandoning exception handling. > > It would be nice to get clarification from the standards body on what > shall happen if EH allocation runs into OOM situations. Undefined behaviour.