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

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).