Skip to content

<utility>: unreachable does not abort in debug builds #6151

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions