diff --git a/src/tools/Exception.h b/src/tools/Exception.h index 0792da371a..4b008fda12 100644 --- a/src/tools/Exception.h +++ b/src/tools/Exception.h @@ -381,10 +381,11 @@ class ExceptionTypeError : #ifdef NDEBUG // These are the versions used when compiling with NDEBUG flag. -// The condition is always true, so that the rest of the statement -// should be optimized away. -#define plumed_dbg_assert(test) plumed_assert(true) -#define plumed_dbg_massert(test,msg) plumed_massert(true,msg) +// The if constexpr(false) gurarantees that the compiler will optimize away the assertion +// We are not using an empty macro becasue the user may want to use the << operator + +#define plumed_dbg_assert(test) if constexpr(false) plumed_assert(true) +#define plumed_dbg_massert(test,msg) if constexpr(false) plumed_massert(true,msg) #else