Created attachment 902693 [details] define gcc--Wparentheses-friendly assert macro Description of problem: "assert (errno = ENOENT);" does not elicit a warning from gcc -Wparentheses This is not a bug, but a request for improvement. Replace glibc's assert macro with a version that does not add parentheses. The default non-empty expansion of assert parenthesizes "expr", and, by enclosing it in parentheses, effectively disables gcc's usual -Wparentheses (part of -Wall) warning. That is the warning that catches the mistake of "if (a = b) ..." when "if (a == b) ..." was intended. Thus, with the default assert definition, gcc cannot warn about the erroneous "assert(a = 1)", but with this replacement, it does. Version-Release number of selected component (if applicable): all How reproducible: every time Steps to Reproduce: printf '%s\n' '#include <assert.h>' \ 'int main() {int a = 1; assert (a = 0); return a;}' > k.c \ && gcc -Wparentheses k.c Actual results: no warning Desired results: a warning like this: k.c:2:1: warning: suggest parentheses around assignment used as truth value [-Wparentheses] Additional info: patch attached
Created attachment 902724 [details] adjusted to use statement expression instead of do...while(0)
Hmm... but using statement expressions may have to be conditional upon not disabling extensions.
Created attachment 914882 [details] assert: fix its definition not to disable -Wparentheses handle __STRICT_ANSI__, too
Created attachment 918486 [details] better patch Add __GNUC__ guard, and fix a typo.
Created attachment 918491 [details] better patch The previous was not the new version. Also fix spaces-vs-TABs.
Created attachment 918554 [details] still better Use __extension__
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle. Changing version to '22'. More information and reason for this action is here: https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
Upstream discussion: https://sourceware.org/ml/libc-alpha/2014-07/msg00394.html
Created attachment 1223507 [details] improved patch