Skip to content

Commit

Permalink
Fix portability of IMMER_THROW when exceptions are disabled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tjaneczko authored Jan 16, 2024
1 parent 5875f77 commit e644569
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion immer/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e644569

Please sign in to comment.