<utility>: attempt to call doom function on unreachable() call in a debug configuration#6159
<utility>: attempt to call doom function on unreachable() call in a debug configuration#6159AlexGuteniev wants to merge 5 commits intomicrosoft:mainfrom
<utility>: attempt to call doom function on unreachable() call in a debug configuration#6159Conversation
stl/inc/utility
Outdated
| _STL_UNREACHABLE; | ||
| #ifdef _DEBUG | ||
| _MSVC_STL_DOOM_FUNCTION("unreachable called"); | ||
| #endif // defined(_DEBUG) |
There was a problem hiding this comment.
The unreachable macro should occur after calling the doom function.
There was a problem hiding this comment.
I like this idea, but remember that it contradicts to what has been decided previously and captured in the comments: #2526 (comment)
There was a problem hiding this comment.
Let's please capture it in a comment, then. Not even my memory is that perfect.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
If we decide on doom before UB, we can also have death runtime coverage. Though it will be complicated to test _DEBUG specific behavior.
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
/clrconfigurations only.Extended test coverage to make sure the machinery does not break compilation.
No runtime coverage -- it is still UB to call
unreachable().