85
85
#ifndef ASSERT_IFNOT
87
#define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : (void)0)
87
* PR 271512: When compiling with gcc, catch assignments inside an ASSERT.
89
* 'UNLIKELY' is defined with __builtin_expect, which does not warn when passed an
90
* assignment (gcc bug 36050).
91
* To get around this, we put 'cond' in an 'if' statement and make sure it never gets
92
* executed by putting that inside of 'if (0)'.
93
* We use gcc's statement expression syntax to make ASSERT an expression because some
94
* code uses it that way.
96
* Since statement expression syntax is a gcc extension and since it's not clear if
97
* this is a problem with other compilers, the ASSERT definition was not changed for
98
* them. Using a bare 'cond' with the ternary operator may provide a solution.
101
#define ASSERT_IFNOT(cond, panic) \
102
({if (UNLIKELY(!(cond))) { panic; if (0) { if (cond) { ; } } } (void)0;})
89
#define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : 0)
104
#define ASSERT_IFNOT(cond, panic) \
105
(UNLIKELY(!(cond)) ? (panic) : (void)0)