C++26 Hardening Turns Out-of-Bounds operator[] Into a Terminate Instead of Undefined Behaviour
The cppstories walkthrough (83 points, 53 comments) explains what standard library hardening actually specifies: not exception-throwing like .at(), but detecting the programming error and terminating rather than allowing memory-unsafe UB, across vector, deque, array, string and string_view, iterator adaptors, shared_ptr<T[N]>, optional and expected, covering front(), back(), operator[] and dereference. Vendors already ship it behind different switches: -D_GLIBCXX_ASSERTIONS or -fhardened on libstdc++, -D_LIBCPP_HARDENING_MODE with FAST/EXTENSIVE/DEBUG on libc++, and -_MSVC_STL_HARDENING=1 on MSVC. Implementations are still incomplete, and the author is clear this is a baseline complementing sanitizers, not memory safety.
↳ Follow the thread