mongo-cxx-driver fails to build on macOS with clang + libc++ when using C++23 due to missing #include <cstdlib> in macros.hpp.
The macro MONGOCXX_PRIVATE_UNREACHABLE in src/mongocxx/include/mongocxx/v1/detail/macros.hpp expands to std::abort(), but the header never includes <cstdlib>. It relies on <cstdlib> being pulled in transitively through other headers.
This works with GCC/libstdc++ and with clang/libc++ under C+11–C20, where <bit> transitively includes <cstdlib> (via bsoncxx's bit.hpp include chain). Under C23, libc+ deliberately drops transitive includes per #if _LIBCPP_STD_VER <= 20 guard in <bit>, so <cstdlib> is no longer pulled in and std::abort() is undeclared.
Affected file: src/mongocxx/lib/mongocxx/private/scoped_bson.hh (uses MONGOCXX_PRIVATE_UNREACHABLE)
Error (clang 22.1.6, libc+, -std=c+23):
scoped_bson.hh:146:13: error: no member named 'abort' in namespace 'std'; did you mean simply 'abort'?
Reproducer:
- Clone mongo-cxx-driver at r4.4.1
- Configure (in this case with LLVM clang toolchain on macOS): -DCMAKE_CXX_STANDARD=23
- Build: fails on scoped_bson.cpp