mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
assert: Support types without operator== (int) [BZ #21972]
This commit is contained in:
@ -85,7 +85,12 @@ __END_DECLS
|
||||
/* 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__
|
||||
# if defined __cplusplus
|
||||
# define assert(expr) \
|
||||
(static_cast <bool> (expr) \
|
||||
? void (0) \
|
||||
: __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
|
||||
# elif !defined __GNUC__ || defined __STRICT_ANSI__
|
||||
# define assert(expr) \
|
||||
((expr) \
|
||||
? __ASSERT_VOID_CAST (0) \
|
||||
@ -93,12 +98,11 @@ __END_DECLS
|
||||
# else
|
||||
/* The first occurrence of EXPR is not evaluated due to the sizeof,
|
||||
but will trigger any pedantic warnings masked by the __extension__
|
||||
for the second occurrence. The explicit comparison against zero is
|
||||
required to support function pointers and bit fields in this
|
||||
context, and to suppress the evaluation of variable length
|
||||
arrays. */
|
||||
for the second occurrence. The ternary operator is required to
|
||||
support function pointers and bit fields in this context, and to
|
||||
suppress the evaluation of variable length arrays. */
|
||||
# define assert(expr) \
|
||||
((void) sizeof ((expr) == 0), __extension__ ({ \
|
||||
((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \
|
||||
if (expr) \
|
||||
; /* empty */ \
|
||||
else \
|
||||
|
Reference in New Issue
Block a user