public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "geoffreydgr at icloud dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [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 Date: Sun, 19 Mar 2023 16:52:24 +0000 [thread overview] Message-ID: <bug-109201-4@http.gcc.gnu.org/bugzilla/> (raw) 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 ```
next reply other threads:[~2023-03-19 16:52 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-19 16:52 geoffreydgr at icloud dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109201-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).