mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 13:25:41 +02:00
Don't follow __assume(false) with std::terminate in NDEBUG builds
Having `std::terminate` as the backstop after `__assume(false)` would trigger W4702 (unreachable code) with MSVC. As we want to keep `__assume(false)` for the optimization hint in NDEBUG builds, we have to avoid mixing in `std::terminate` for those builds. Fixes #3007
This commit is contained in:
@@ -39,9 +39,13 @@ namespace Catch {
|
|||||||
__assume( false );
|
__assume( false );
|
||||||
# elif defined( __GNUC__ )
|
# elif defined( __GNUC__ )
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
# endif
|
# else // vv platform without known optimization hint
|
||||||
# endif // ^^ NDEBUG
|
|
||||||
std::terminate();
|
std::terminate();
|
||||||
|
# endif
|
||||||
|
# else // ^^ NDEBUG
|
||||||
|
// For non-release builds, we prefer termination on bug over UB
|
||||||
|
std::terminate();
|
||||||
|
# endif //
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
|
Reference in New Issue
Block a user