From fc7a60f9d2b9c2c8a436d1e344f5d1c0cf7010a0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 11 Dec 2008 13:36:45 +0000 Subject: [PATCH] Fix BUILD_BUG_ON() As was noticed on the Linux side, using an array here isn't appropriate if the condition is not a compile time constant - gcc allows such arrays, and hence the intended effect of producing a compiler error is not achieved in that case. Bit field widths do not know similar language extensions, and hence always produce a compiler error. Signed-off-by: Jan Beulich xen-unstable changeset: 18899:1419a73316e1d75d3e5d7c1530ac6ae7e7bc7fb4 xen-unstable date: Thu Dec 11 11:19:01 2008 +0000 --- xen/include/xen/lib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index d6aa891eb..cbadd0de1 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -16,7 +16,7 @@ void __warn(char *file, int line); #define WARN_ON(p) do { if (p) WARN(); } while (0) /* Force a compilation error if condition is true */ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) +#define BUILD_BUG_ON(condition) ((void)sizeof(struct { int:-!!(condition); })) #ifndef assert_failed #define assert_failed(p) \ -- 2.39.5