Bug 1676607
Summary: | False? warning: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C2 -+ C1 [-Wstrict-overflow] | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Petr Lautrbach <plautrba> | ||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
Severity: | unspecified | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | rawhide | CC: | aoliva, davejohansen, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2019-02-12 16:44:31 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: |
|
Description
Petr Lautrbach
2019-02-12 16:34:53 UTC
Can you explain why you think it is a false positive? This warning is totally useless warning, where the compiler just tells the user it does its job, optimizing code based on the assumption that undefined behavior does not happen. Unless you know what you are doing, enabling this warning doesn't really make much sense. The warning above is about len - 1 >= 0 being optimized into len >= 1, which can be done only because INT_MIN - 1 >= 0 would trigger undefined behavior. As I said, the warning is just logging that the compiler has done some optimization (that checks the -Wstrict-overflow=*) and used the assumption there is no UB, it is not guarded by further analysis what the value range of the variable is etc. (using that wouldn't be very useful, because the value range computation also relies on signed integer overflow not happening heavily). I probably didn't use right words. This warning and apparently other warnings are new in gcc 9. gcc-8.2.1-6.fc29.x86_64 doesn't log that. Thanks for the explanation. |