Describe the bug
Calling std::unreachable is not diagnosed in debug builds.
Expected behavior
In debug builds, I would expect calling std::unreachable to abort execution.
STL version
e2115ba
Additional context
This was discovered after std::terminate failed to capture undefined behavior due to a logic error. Aborting execution is compatible with undefined behavior, and it helps catch bugs. In that regard, the old assert(false)-based implementations are preferable to std::unreachable().
The original implementation (#2526) attempted to call abort in debug builds:
|
_CSTD abort(); // likely to be called in debug mode, but can't be relied upon - already entered the UB territory
|
This was later removed in (#5560), with no obvious explanation for the rationale.
e2115ba#diff-b40b803e74da64226183307c996e495cce0bf23a9c83d9822fea849bb99b7144L962
Describe the bug
Calling
std::unreachableis not diagnosed in debug builds.Expected behavior
In debug builds, I would expect calling
std::unreachableto abort execution.STL version
e2115ba
Additional context
This was discovered after
std::terminatefailed to capture undefined behavior due to a logic error. Aborting execution is compatible with undefined behavior, and it helps catch bugs. In that regard, the oldassert(false)-based implementations are preferable tostd::unreachable().The original implementation (#2526) attempted to call
abortin debug builds:STL/stl/inc/utility
Line 757 in b6b9778
This was later removed in (#5560), with no obvious explanation for the rationale.
e2115ba#diff-b40b803e74da64226183307c996e495cce0bf23a9c83d9822fea849bb99b7144L962