[Bug analyzer/109063] New: GCC Static Analyzer evaluates `e == &d + 1` to be UNKNOWN with the fact that `e == &d`
geoffreydgr at icloud dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 8 08:41:32 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109063
Bug ID: 109063
Summary: GCC Static Analyzer evaluates `e == &d + 1` to be
UNKNOWN with the fact that `e == &d`
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: ---
Hi, David. I found a problem that GCC Static Analyzer evaluates `e == &d + 1`
to be UNKNOWN with the fact that `e == &d`.
Maybe GCC Static Analyzer should have the ability to evaluates `e == &d + 1` to
be FALSE ?
See it live: https://godbolt.org/z/Wcd4T1jGa.
Input:
```c
void __analyzer_eval();
void __analyzer_describe();
void c()
{
int d = 42;
int *e = &d;
if (e == &d)
{
__analyzer_describe(0, e);
__analyzer_describe(0, &d + 1);
__analyzer_eval(e == &d + 1);
__analyzer_eval(e + 1 == &d + 1);
}
}
```
Output:
```bash
<source>: In function 'c':
<source>:11:9: warning: svalue: '&d'
11 | __analyzer_describe(0, e);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
<source>:12:9: warning: svalue: '(&d+(sizetype)4)'
12 | __analyzer_describe(0, &d + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:14:9: warning: UNKNOWN
14 | __analyzer_eval(e == &d + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:9: warning: TRUE
15 | __analyzer_eval(e + 1 == &d + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler returned: 0
```
More information about the Gcc-bugs
mailing list