Bug 1105335
| Summary: | assert (errno = ENOENT) cannot be detected by gcc -Wparentheses | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Jim Meyering <jim> | ||||||||||||||||
| Component: | glibc | Assignee: | Carlos O'Donell <codonell> | ||||||||||||||||
| Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||||||||||||
| Severity: | unspecified | Docs Contact: | |||||||||||||||||
| Priority: | unspecified | ||||||||||||||||||
| Version: | rawhide | CC: | codonell, fweimer, jakub, law, mnewsome, pfrankli | ||||||||||||||||
| Target Milestone: | --- | Keywords: | FutureFeature, Reopened | ||||||||||||||||
| Target Release: | --- | ||||||||||||||||||
| Hardware: | All | ||||||||||||||||||
| OS: | All | ||||||||||||||||||
| Whiteboard: | |||||||||||||||||||
| Fixed In Version: | glibc-2.24.90-24.fc26 | Doc Type: | Bug Fix | ||||||||||||||||
| Doc Text: | Story Points: | --- | |||||||||||||||||
| Clone Of: | Environment: | ||||||||||||||||||
| Last Closed: | 2016-12-19 07:32:58 UTC | Type: | Bug | ||||||||||||||||
| Regression: | --- | Mount Type: | --- | ||||||||||||||||
| Documentation: | --- | CRM: | |||||||||||||||||
| Verified Versions: | Category: | --- | |||||||||||||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||||||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||||||||||||
| Embargoed: | |||||||||||||||||||
| Attachments: |
|
||||||||||||||||||
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
|
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