https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108860
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- This fixes it for GCC 14, but I'm not sure why the compiler can't tell this isn't true already: --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -833,6 +833,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_check_len(__n, "vector::_M_default_append"); pointer __new_start(this->_M_allocate(__len)); + if (!__new_start) + __builtin_unreachable(); + // RAII guard for allocated storage. struct _Guard {