From 6e16dfa5e5592e9662f839a9696f2863e2428bc5 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 25 Jul 2022 21:34:57 +0200 Subject: [PATCH] use defines for unreachable --- src/defines.hpp | 6 ++++++ src/helpers/AnimatedVariable.hpp | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/defines.hpp b/src/defines.hpp index 375f0119..ecad02aa 100644 --- a/src/defines.hpp +++ b/src/defines.hpp @@ -54,6 +54,12 @@ #define ASSERT(expr) RASSERT(expr, "?") +#if ISDEBUG +#define UNREACHABLE() { Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); *((int*)nullptr) = 1; } +#else +#define UNREACHABLE() std::unreachable(); +#endif + // git stuff #ifndef GIT_COMMIT_HASH #define GIT_COMMIT_HASH "?" diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index d8fd3c4c..7b02ba6c 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -129,10 +129,12 @@ public: case AVARTYPE_COLOR: return m_cValue != m_cGoal; default: - std::unreachable(); + UNREACHABLE(); } - std::unreachable(); + UNREACHABLE(); + + return false; // just so that the warning is suppressed } void warp() { @@ -150,7 +152,7 @@ public: break; } default: - std::unreachable(); + UNREACHABLE(); } }