Rewrite fmt::throw_exception destructor

Add _DEBUG in debug mode for consistency with MSVC.
This commit is contained in:
Nekotekina 2021-01-18 13:49:16 +03:00
parent 0070fce286
commit e07484f057
2 changed files with 14 additions and 1 deletions

View file

@ -36,6 +36,8 @@ endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DNDEBUG)
elseif(NOT MSVC)
add_definitions(-D_DEBUG)
endif()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)

View file

@ -297,7 +297,18 @@ namespace fmt
raw_throw_exception({line, col, file, func}, reinterpret_cast<const char*>(fmt), type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
[[noreturn]] ~throw_exception() { std::abort(); } // Unreachable
#ifdef _DEBUG
[[noreturn]] ~throw_exception()
{
#ifdef _MSC_VER
__assume(false);
#else
__builtin_unreachable();
#endif
}
#else
[[noreturn]] ~throw_exception();
#endif
};
template <typename CharT, usz N, typename... Args>