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
```