From 0eadcc555a799506702a9db8b13185e558e77ec0 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 18 Aug 2022 23:29:25 +0200 Subject: [PATCH] Util: Fix asserts in release mode --- src/ruc/meta/assert.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ruc/meta/assert.h b/src/ruc/meta/assert.h index 714a465..ce5c380 100644 --- a/src/ruc/meta/assert.h +++ b/src/ruc/meta/assert.h @@ -16,19 +16,24 @@ #include "ruc/format/format.h" #include "ruc/meta/compiler.h" -#define CRASH() asm volatile("int $0x03"); +#define CRASH() ruc::__crash() #ifndef NDEBUG #define VERIFY(expr, ...) (static_cast(expr) ? (void)0 : ruc::__assertion_failed(#expr, __FILE__, __LINE__, FUNCTION_MACRO __VA_OPT__(, ) __VA_ARGS__)) #define VERIFY_NOT_REACHED() VERIFY(false) #else - #define VERIFY(expr, ...) (static_cast(expr) ? (void)0 : CRASH() - #define VERIFY_NOT_REACHED() CRASH() + #define VERIFY(expr, ...) (static_cast(expr) ? (void)0 : CRASH()) + #define VERIFY_NOT_REACHED() VERIFY(false) #endif -#ifndef NDEBUG namespace ruc { +inline void __crash() +{ + asm volatile("int $0x03"); +} + +#ifndef NDEBUG template inline void __assertion_failed(const char* assertion, const char* file, uint32_t line, const char* function, const Parameters&... parameters) { @@ -91,6 +96,6 @@ inline void __assertion_failed(const char* assertion, const char* file, uint32_t CRASH(); } +#endif } // namespace ruc -#endif