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

    <tr>
        <th>Summary</th>
        <td>
            clang with -Wnull-dereference doesn't produce expected warning
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          tklengyel
      </td>
    </tr>
</table>

<pre>
    Greetings,
while compiling the following program with `-Wnull-dereference` no warning is produced by clang (`Ubuntu clang version 20.0.0 (++20241009053718+c198f775cdcd-1~exp1~20241009053853.1977`):
```c
#include <stdio.h>

int main(int argc, char **argv)
{
    int *yikes = NULL;
    *yikes = 1;

    fprintf(stdout, "Hello world!\n");

    return *yikes;
}
```

Expected result would be like what you get with gcc (although it only seems to work with gcc if you have optimizations enabled and not with -O0):
```
$ gcc -O1 -Wnull-dereference -o yikes yikes.c
yikes.c: In function ‘main’:
yikes.c:8:12: warning: null pointer dereference [-Wnull-dereference]
    8 |     *yikes = 1;
      |     ~~~~~~~^~~
yikes.c:12:12: warning: null pointer dereference [-Wnull-dereference]
   12 |     return *yikes;
      |            ^~~~~~
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2T4yYQ_TWtS5ddCCxLOujgj3GSqq3saStnCdoSGQwuQPY6B__2lD48nt2Z5LQql0yLfvSD9-g6BN1aogqyLWT7pO5j53wVXw3Z9kYmaZy6Vb95oqhtG4DvgO2Bba6dNoTSnc7aaNti7AiPzhh3HaKzd62vT3jVsUNYs8VftjdmocjTkTxZSbBmaB1ea28HgA4DRvWSFDY3lKa2LQIvYM2-Nb2N_fzpQj5oZ5GzJVuyMYNvgW8546uUsZJlIk-HbzIti2OeZ1JJtUjv9P2c3t8lFZlYpmWew5oBL0Fspl0N4fiTc8yFttL0ihDELkSl3bID8TLPjm9tI55qbYEXw7D2rQS-Q9nVHoFvgG9q316GKhMo304DRMQBAHxz068UEMQe__z25QuIdxk_zKZvU8-E49lrG4_AixCV6-NQGzj_nYxxeHXeKOApZDsLnI9b_bCCp9h7-1bpmZHvfzqV98iX72eSkRR6Cr2JeHW9UdgQGv1KeO3qiDfXY0txckEr5SBXbWLn-rZDHdFZc8NAdAoYR66vz1R9HOFdfSF056hP-p86amcDkq0bQwprq9C6efXF1891fMi4GhddfE3xoxVx4XA64_G9nLV_BGKDf1g89lYO9RFeOBQMymLUfA6elZ-oAsQm5QN8NvkwHGrj2WkbyeN7DpBtP7kk2f4pU4GQ7_B_PIHT5Jx0nx7IXu73n6mNtH4ht5S_lf0vM_1Ibn5GcvcHvzfRElUJVYqyTqhKc16KQmRplnQVL1XdNMecciqFEMWKKGer1VrSWjZEZaKr6Y5zxlhaiGzJBOdSpCummCzS9RFWjE61NktjLqel822iQ-ipSlPB1kVi6oZMGHsh52PHGW5Ntk98NQAWTd8GWDGjQwzPJaKOhqqpQU1u_Ogx5ShY4Hl89DmkxwWaJUh6b6ouxnMYzMQPwA-tjl3fLKU7AT8M5ea_xdm7v0lG4IeRfgB-mHdwqfi_AQAA___OlbzH">