assert.h: allow gcc to detect assert(a = 1) errors
authorJim Meyering <meyering@fb.com>
Thu, 5 Jun 2014 17:42:05 +0000 (10:42 -0700)
committerJim Meyering <meyering@fb.com>
Sun, 18 Dec 2016 09:30:51 +0000 (01:30 -0800)
commite077349ce589466eecd47213db4fae6b80ec18c4
tree3f8dc06410c398f69426bf115e643284a133436b
parent009ba649b4999ea269de8d0b301e659f075df495
assert.h: allow gcc to detect assert(a = 1) errors

* assert/assert.h (assert): Rewrite assert's definition so that
a s/==/=/ typo, e.g., assert(errno = ENOENT) is not hidden from
gcc's -Wparentheses by assert-added parentheses.  The new definition
uses "if (expr) /* empty */; else __assert_fail...", so
gcc -Wall will now detect that type of error in an assert, too.
The __STRICT_ANSI__ disjunct is to make this work also with both
-ansi and  -pedantic, which would reject the use of ({...}).
I would have preferred to use __extension__ to mark that, but
doing so would mistakenly suppress warnings about any extension
in the user-supplied "expr".
E.g., "assert ( ({1;}) )" must continue to evoke a warning.
ChangeLog
assert/assert.h