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

    <tr>
        <th>Summary</th>
        <td>
            [clang static analyzer] core.NullDereference false positive with `*p = 42`
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          0-0x41
      </td>
    </tr>
</table>

<pre>
    I got a false positive error when compiling the following program with clang(trunk) `--analyze -Xclang -analyzer-stats -Xclang -analyzer-checker=core,debug.ExprInspection` in https://godbolt.org/z/nEMcfT883.

In this case, the judgment condition of the if statement should be FALSE and its inner code is unreachable code. However, in line 11, analyzer gives FALSE for `(d[0].b && 1) == false`. This is a little odd. Here is the analysis result of the case. Thank you for taking the time to review this case.

Input:

```c
#include "stdio.h"
#include <stdbool.h>
void clang_analyzer_eval();

union a
{
    int b
} c()
{
 union a d[1] = {0};
    int *p = (int *)0;
 clang_analyzer_eval((d[0].b && 1) == false);
    if (d[0].b && 1)
 {
        *p = 42;
 }
}

```

Output:

```bash
<source>:11:5: warning: FALSE [debug.ExprInspection]
    clang_analyzer_eval((d[0].b && 1) == false);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:14:12: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
        *p = 42;

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zgM_TXMhYhhy3FsH3JI6gZTYD8OO4e9DWSZtjVVJEOSk-kc9rcvpCRNJ9su5jBG4UakRPK9Z5HcOTloog0UOyiaBZ_9aOwmXabfVtmiNd3L5gkH45Fjz5UjnIyTXh4JyVpj8TSSRmEOk1RSD-hHwt4oZU5hNVkzWH7Ak_QjCsX1AKzydtbPwGqEdbpccs3Vy3fC5d_Rj1eDXTrPvXvHLkYSz2Qhb4SxBO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