Reference:
(msvc) __assume
(gcc/clang) __builtin_unreachable()
(c++23) std::unreachable
[[noreturn]] inline void unreachable()
{
// Uses compiler specific extensions if possible.
// Even if no extension is used, undefined behavior is still raised by
// an empty function body and the noreturn attribute.
#ifdef __GNUC__ // GCC, Clang, ICC
__builtin_unreachable();
#elifdef _MSC_VER // MSVC
__assume(false);
#endif
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.