From fc427c6fab29c0af1441e5c2f80602d6ebd6c49b Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 22 Jan 2017 21:06:05 -0800 Subject: [PATCH] nasmlib.h: slightly tidy up the definition of nasm_build_assert() "Assertion failed" is likely to be redundant with static_assert(). __attribute__((error)) is only guaranteed to work while optimizing, so do not use it unless __OPTIMIZE__ is defined. Signed-off-by: H. Peter Anvin --- include/nasmlib.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nasmlib.h b/include/nasmlib.h index ea297b5d..3738e3b7 100644 --- a/include/nasmlib.h +++ b/include/nasmlib.h @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2016 The NASM Authors - All Rights Reserved + * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -176,13 +176,13 @@ no_return nasm_assert_failed(const char *, int, const char *); * NASM failure at build time if x != 0 */ #ifdef static_assert -# define nasm_build_assert(x) static_assert(x, "assertion " #x " failed") -#elif defined(HAVE_FUNC_ATTRIBUTE_ERROR) +# define nasm_build_assert(x) static_assert(x, #x) +#elif defined(HAVE_FUNC_ATTRIBUTE_ERROR) && defined(__OPTIMIZE__) # define nasm_build_assert(x) \ if (!(x)) { \ - extern void __attribute__((error("assertion " #x " failed"))) \ - fail(void); \ - fail(); \ + extern void __attribute__((error("assertion " #x " failed"))) \ + _nasm_static_fail(void); \ + _nasm_static_fail(); \ } #else # define nasm_build_assert(x) (void)(sizeof(char[1-2*!(x)])) -- 2.11.4.GIT