From dd65cf2dc0244dd4130565db62d152a4bc57e6ec Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 23 Jun 2022 15:01:14 +0100 Subject: [PATCH] utils/macros.h (STATIC_ASSERT): Boolean-canonify the expression. 6.7.10p3 insists that the expression be an integer constant expression, but this isn't in a constraint, so the behaviour is undefined if it's not an integer constant expression. Apply `!!' to force pointerish expressions to integer type. *headdesk* --- utils/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/macros.h b/utils/macros.h index a5263e1..45420e2 100644 --- a/utils/macros.h +++ b/utils/macros.h @@ -51,7 +51,7 @@ #define GLUE(x, y) MLIB__GLUE(x, y) #ifdef static_assert -# define STATIC_ASSERT(cond, msg) static_assert(cond, msg) +# define STATIC_ASSERT(cond, msg) static_assert(!!(cond), msg) #else # define STATIC_ASSERT(cond, msg) \ IGNORABLE extern char static_assert_failed[2*!!(cond) - 1] -- 2.11.0