Skip to content

<utility>: attempt to call doom function on unreachable() call in a debug configuration#6159

Open
AlexGuteniev wants to merge 5 commits intomicrosoft:mainfrom
AlexGuteniev:failsafe
Open

<utility>: attempt to call doom function on unreachable() call in a debug configuration#6159
AlexGuteniev wants to merge 5 commits intomicrosoft:mainfrom
AlexGuteniev:failsafe

Conversation

@AlexGuteniev
Copy link
Contributor

Fix #6151.

Attempt to call doom function on unreachable() call in a debug configuration.
Still preserve UB and attempt to call doom function after _STL_UNREACHABLE.

Extract doom function to a new core header to achieve that. As @frederick-vs-ja suggested, core headers do call some functions. In this case, a function will be called by default for /clr configurations only.

Extended test coverage to make sure the machinery does not break compilation.
No runtime coverage -- it is still UB to call unreachable().

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner March 14, 2026 08:17
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Mar 14, 2026
stl/inc/utility Outdated
Comment on lines +1017 to +1020
_STL_UNREACHABLE;
#ifdef _DEBUG
_MSVC_STL_DOOM_FUNCTION("unreachable called");
#endif // defined(_DEBUG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unreachable macro should occur after calling the doom function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, but remember that it contradicts to what has been decided previously and captured in the comments: #2526 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please capture it in a comment, then. Not even my memory is that perfect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First please clarify how do you want it -- as it was agreed upon previously, and as you suggested it and I want it to be (I pushed a change already before seeing your comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide on doom before UB, we can also have death runtime coverage. Though it will be complicated to test _DEBUG specific behavior.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

<utility>: unreachable does not abort in debug builds

2 participants