https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109200

            Bug ID: 109200
           Summary: GCC Static Analyzer does not generate a div-by-zero
                    warning for the `0 <= (f = 0) % e.b` where `e.b == 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 `0 <= (f =
0) % e.b` statement, but if it is changed to `0 <= (f = 0) % 0`, analyzer
generates that warning.

See it live: https://godbolt.org/z/PYoroM8hx

Input:
```c
void __analyzer_eval();

union a
{
  int b;
} ;
void c(){
  union a e;
  int f;
  e.b = 0;
  if (0 <= (f = 0) % e.b)
  // if (0 <= (f = 0) % 0)
  {
    __analyzer_eval(0 <= (f = 0) % e.b);
  }
}
```

Output:
```
<source>: In function 'c':
<source>:14:5: warning: TRUE
   14 |     __analyzer_eval(0 <= (f = 0) % e.b);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler returned: 0
```
  • [Bug analyzer/109200] New: GCC ... geoffreydgr at icloud dot com via Gcc-bugs

Reply via email to