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