Dev/annagrin/failfast in noexcept mode windows (#710)

made terminate call __fastfail in noexcept mode when using msvc
This commit is contained in:
Anna Gringauze 2018-07-31 17:30:43 -07:00 committed by GitHub
parent 5778149583
commit 1f76fbd168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,8 @@
// //
#if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS #if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
#define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND #define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND
#include <intrin.h>
#define RANGE_CHECKS_FAILURE 0
#endif #endif
// //
@ -83,9 +85,14 @@ namespace details
typedef void (__cdecl *terminate_handler)(); typedef void (__cdecl *terminate_handler)();
[[noreturn]] inline void __cdecl default_terminate_handler()
{
__fastfail(RANGE_CHECKS_FAILURE);
}
inline gsl::details::terminate_handler& get_terminate_handler() noexcept inline gsl::details::terminate_handler& get_terminate_handler() noexcept
{ {
static terminate_handler handler = &abort; static terminate_handler handler = &default_terminate_handler;
return handler; return handler;
} }