+2016-11-25 Jim Meyering <meyering@fb.com>
+
+ Let gcc detect assert(a = 1) errors.
+ * assert/assert.h (assert) Rewrite, retaining the old definintion
+ when required, but otherwise putting the expression as-is in an "if"
+ expression (hence, with no added parentheses) within a statement
+ expression.
+
2016-12-17 Siddhesh Poyarekar <siddhesh@sourceware.org>
* benchtests/Makefile (binaries-benchset): Depend on libsupport
__END_DECLS
-# define assert(expr) \
- ((expr) \
- ? __ASSERT_VOID_CAST (0) \
- : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
+/* When possible, define assert so that it does not add extra
+ parentheses around EXPR. Otherwise, those added parentheses would
+ suppress warnings we'd expect to be detected by gcc's -Wparentheses. */
+# if !defined __GNUC__ || defined __STRICT_ANSI__
+# define assert(expr) \
+ ((expr) \
+ ? __ASSERT_VOID_CAST (0) \
+ : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
+# else
+# define assert(expr) \
+ ({ \
+ if (expr) \
+ ; /* empty */ \
+ else \
+ __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \
+ })
+# endif
# ifdef __USE_GNU
# define assert_perror(errnum) \