<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59963>59963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
CSA evaluates `( ((b)-0) <= ((c)-0) ) == false` to be FALSE in the true branch of `if (c >= b)`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Geoffrey1014
</td>
</tr>
</table>
<pre>
Hi, I found a problem that CSA evaluates `( ((b)-0) <= ((c)-0) ) == false` to be FALSE in the true branch of `if (c >= b)` where `b` and `c` are both pointer varibles.
https://godbolt.org/z/bPYsTzEMj
Input:
```c
#include "stdio.h"
#include <stdint.h>
#include <stdbool.h>
void clang_analyzer_eval(int){}
int a(int* b, int *c) {
d:
if (c >= b) {
clang_analyzer_eval((c >= b)==true);
clang_analyzer_eval(((b)+0)<=((c)+0));
clang_analyzer_eval(((b)-0)<=((c)-0));
clang_analyzer_eval((!(c >= b))==false);
clang_analyzer_eval((((c)<=(b))&&((c)!=(b)))==false);
clang_analyzer_eval(true);
goto d;
}
}
```
Output:
```bash
<source>:10:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval((c >= b)==true);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:11:5: warning: FALSE [debug.ExprInspection]
clang_analyzer_eval(((b)+0)<=((c)+0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:11:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval(((b)+0)<=((c)+0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:5: warning: FALSE [debug.ExprInspection]
clang_analyzer_eval(((b)-0)<=((c)-0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval(((b)-0)<=((c)-0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval((!(c >= b))==false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:16:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval((((c)<=(b))&&((c)!=(b)))==false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:17:5: warning: TRUE [debug.ExprInspection]
clang_analyzer_eval(true);
^~~~~~~~~~~~~~~~~~~~~~~~~
===-------------------------------------------------------------------------===
Analyzer timers
===-------------------------------------------------------------------------===
Total Execution Time: 0.0057 seconds (0.0181 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
0.0033 ( 88.6%) 0.0003 ( 14.3%) 0.0036 ( 63.8%) 0.0102 ( 56.3%) Path exploration time
0.0001 ( 2.3%) 0.0004 ( 21.9%) 0.0005 ( 8.8%) 0.0048 ( 26.4%) Syntax-based analysis time
0.0003 ( 9.1%) 0.0012 ( 63.8%) 0.0015 ( 27.3%) 0.0031 ( 17.3%) Path-sensitive report post-processing time
0.0038 (100.0%) 0.0019 (100.0%) 0.0057 (100.0%) 0.0181 (100.0%) Total
8 warnings generated.
Compiler returned: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8V8mO2zgTfhr6UpDAxZKlgw9uL_8fYJZguoPBnAJKKlvMyKJBUr3kMM8-IGW3l3Yn7onTtmBTX7GWr6pEqKS1atUijklyQ5LZQHau1mb8P9TLpcEnRtlwUOjqafx_RfgUPsBSd20FEjZGFw2uwdXSwfR2Angvm046tEBSSngGhGeEZwXheUQJz4GIKRGzLVzu4SCaedFSNhZJSgGchgJhMfnldg6qBVcjONMhFEa2ZQ16Cd6LWnprJRAx9-reldd-qNGglxf-TraVX5dhbRAK7WrYaNU6NHAvjSoatDGhM0In_W_t3MYSMSF8QfhipatCNy7WZkX44iv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