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

    <tr>
        <th>Summary</th>
        <td>
            [False negative] -Wpointer-integer-compare fails on comparison between a pointer and zero
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          vincent-mailhol
      </td>
    </tr>
</table>

<pre>
    The [`-Wpointer-integer-compare`](https://clang.llvm.org/docs/DiagnosticsReference.html#wpointer-integer-compare) diagnostic is not emitted when a pointer is compared against the literal zero.

**Minimum reproducer:**

```c
int is_positive(int *a)
{
    return a >= 0;
}
```
**Link:** https://godbolt.org/z/PYeh8P5dT

In above example, the developer probably intended to compare the pointed value `*a` instead of the pointer `a`. However clang yields no warning even if explicitly given the `-Wpointer-integer-compare` command line argument.

Comparison with non-zero literal integers seem to work fine. So, I suspect that the root cause is that `-Wpointer-integer-compare` treats literal zero as the `NULL` pointer instead of as an integer. But then `-Wcompare-distinct-pointer-types` should catch it and doesn't. Refer to https://godbolt.org/z/157n4W7en for an illustration on this root cause investigation.

**N.B.:** gcc would emit a `-Wextra` message on above example: https://godbolt.org/z/YGzP3e5sv.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE1v4zYQ_TX0ZWBBpixLOugQr-t2gXQRtFss9lRQ5FhilyIFciTH-fUF5Y_Eiw0CEEpMvuG8eXwzIgTdWsSa5VuW7xZipM75etJWoqVlL7TpnFk0Tp3qrx1ChG3S5bfBaUvol_Hbol9K1w_CI9ukLN8xXnZEQ2DZA-N7xvfSCNsmxkx94nzL-F45GRjf77RorQukZfgLD-jRSkw66g3j2fG9FLwCdYsDHcA6Auw1ESo4dmhBwCU2nl7CFIhWaBsIqEMwmtALAy_oXcLSHUsfLl8e15_a6n7swePgnRol-rmUeb0Fb9Lzkuff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