public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug analyzer/109201] New: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 @ 2023-03-19 16:52 geoffreydgr at icloud dot com 2023-03-20 20:07 ` [Bug analyzer/109201] " dmalcolm at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: geoffreydgr at icloud dot com @ 2023-03-19 16:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109201 Bug ID: 109201 Summary: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: geoffreydgr at icloud dot com Target Milestone: --- GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` statement, but if it is changed to `if ((d.b = 1) / 0)`, analyzer generates that warning. See it live: https://godbolt.org/z/3f18j9az7 Input: ```c void __analyzer_eval(); struct a { int b : 6; } c() { struct a d; int e = 2; int f = 0; if ((d.b = 1) / f) if (1 >= d.b <= e) { __analyzer_eval(0 >= d.b <= e); } } ``` Output: ``` <source>: In function 'c': <source>:15:13: warning: TRUE 15 | __analyzer_eval(0 >= d.b <= e); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compiler returned: 0 ``` ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug analyzer/109201] GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 2023-03-19 16:52 [Bug analyzer/109201] New: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 geoffreydgr at icloud dot com @ 2023-03-20 20:07 ` dmalcolm at gcc dot gnu.org 2023-03-20 20:08 ` dmalcolm at gcc dot gnu.org 2023-03-20 20:13 ` dmalcolm at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: dmalcolm at gcc dot gnu.org @ 2023-03-20 20:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109201 --- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> --- The division by zero warning on: if ((d.b = 1) / 0) is from -Wdiv-by-zero, which isn't from the analyzer ( https://godbolt.org/z/433PhKhvM ) The analyzer currently only implements -Wanalyzer-tainted-divisor for attacker-controlled values used in division; it doesn't check for zero itself. So this seems like more of an RFE: it sounds like you'd want the analyzer to complain about known zero values reaching a division, as a souped-up kind implementation of the existing -Wdiv-by-zero. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug analyzer/109201] GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 2023-03-19 16:52 [Bug analyzer/109201] New: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 geoffreydgr at icloud dot com 2023-03-20 20:07 ` [Bug analyzer/109201] " dmalcolm at gcc dot gnu.org @ 2023-03-20 20:08 ` dmalcolm at gcc dot gnu.org 2023-03-20 20:13 ` dmalcolm at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: dmalcolm at gcc dot gnu.org @ 2023-03-20 20:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109201 --- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> --- *** Bug 109200 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug analyzer/109201] GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 2023-03-19 16:52 [Bug analyzer/109201] New: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 geoffreydgr at icloud dot com 2023-03-20 20:07 ` [Bug analyzer/109201] " dmalcolm at gcc dot gnu.org 2023-03-20 20:08 ` dmalcolm at gcc dot gnu.org @ 2023-03-20 20:13 ` dmalcolm at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: dmalcolm at gcc dot gnu.org @ 2023-03-20 20:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109201 David Malcolm <dmalcolm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> --- We already have PR 99669 as an RFE for this; marking as a dup. *** This bug has been marked as a duplicate of bug 99669 *** ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-20 20:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-19 16:52 [Bug analyzer/109201] New: GCC Static Analyzer does not generate a div-by-zero warning for the `if ((d.b = 1) / f)` where `f` is 0 geoffreydgr at icloud dot com 2023-03-20 20:07 ` [Bug analyzer/109201] " dmalcolm at gcc dot gnu.org 2023-03-20 20:08 ` dmalcolm at gcc dot gnu.org 2023-03-20 20:13 ` dmalcolm at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).