From e64456925579731fe98b7658c025c1a7a3d33bd4 Mon Sep 17 00:00:00 2001 From: Ted Janeczko Date: Tue, 16 Jan 2024 09:27:44 -0800 Subject: [PATCH] Fix portability of IMMER_THROW when exceptions are disabled The current implementation of IMMER_THROW when exceptions are disabled relies on the compiler converting a character array to a truthy value, which can throw warnings and is not truly portable. Instead, we can use the comma operator to portably add additional data to an assertion: https://en.cppreference.com/w/cpp/error/assert. --- immer/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/immer/config.hpp b/immer/config.hpp index 2e8378f6..af34e5f1 100644 --- a/immer/config.hpp +++ b/immer/config.hpp @@ -33,7 +33,7 @@ #define IMMER_CATCH(expr) else #define IMMER_THROW(expr) \ do { \ - assert(!#expr); \ + assert((#expr, false)); \ std::terminate(); \ } while (false) #define IMMER_RETHROW