<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62181>62181</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang static analyzer make an imprecise assumption for `x > 0`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hallo-wereld
      </td>
    </tr>
</table>

<pre>
    version: clang trunk
args: `--analyze -Xclang -analyzer-stats -Xclang -analyzer-checker=core,debug.ExprInspection -Xanalyzer -analyzer-constraints=z3 --analyzer-output text`

For this case, where `x` is never 0, however, the analyzer makes an imprecise assumption: "assuming 'x' is 0".

input:

```c
extern void clang_analyzer_explain();

int foo(int *p)
{
    unsigned x = (unsigned)p;
    x = x * x + 1;
    clang_analyzer_explain(x);
 if (x)
    {
        return x;
    }
    else
    {
 int *q = (int *)x;
        return *q;
 }
}
```

output:

```console
7:5: warning: symbol of type 'unsigned int' conjured at statement 'x * x + 1' [debug.ExprInspection]
    clang_analyzer_explain(x);
 ^~~~~~~~~~~~~~~~~~~~~~~~~
7:5: note: symbol of type 'unsigned int' conjured at statement 'x * x + 1'
 clang_analyzer_explain(x);

4:5: note: Value assigned to 'x'
    x = x * x + 1;
    ^~~~~~~~~~~~~
5:9: note: Assuming 'x' is 0
    if (x)
        ^
5:5: note: Taking false branch
    if (x)
 ^
11:9: note: 'q' initialized to a null pointer value
        int *q = (int *)x;
        ^~~~~~
12:16: note: Dereference of null pointer (loaded from variable 'q')
        return *q;
 ^~
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVc2O4zYMfhrmQiSw5fjv4EOmmQC9F8XeFrJNx9pRJK8kZzx72GcvZMdJnGaKXaBGoEgk9fEjRYLcWnFURAXELxDvV7x3rTZFy6XU63cyJOtVqeuP4kzGCq0g2mEluTqiM716g2APwY6bo_UKSIL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