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

    <tr>
        <th>Summary</th>
        <td>
            -Wnull-pointer-arithmetic and -Wno-gnu
        </td>
    </tr>

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

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

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

<pre>
    The following code w/ ToT LLVM (clang-15) produces the following warnings:

```c
void *x(void) {
    return (char*)0 + 42;
}

void *y(void) {
    return (void*)0 + 42;
}
```
```
<source>:2:21: warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic]
    return (char*)0 + 42;
           ~~~~~~~~ ^
<source>:6:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
    return (void*)0 + 42;
           ~~~~~~~~ ^
```
for the Linux kernel, we're using `-std=gnu11 -Wno-gnu`, so we should not be observing ANY warnings that we're using GNU C extensions.

I suspect that these two checks should be split into two different named command line flags, such that the one pertaining to GNU C extensions is placed within the `-Wgnu` flag group, such that `-Wno-gnu` implicitly disables it.

cc @AaronBallman @andykaylor 

(link #4440)

As reported in [this thread](https://lore.kernel.org/llvm/20220316183833.1563139-1-arnd@kernel.org/).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVMtu2zoQ_Rp6M7Chpy0ttHBeRYHcrtIWd0lRI4s1RQp8xPHf36Ecx3GR26IVZEn0DA_PmTlka7pj8zQg9EYpc5B6B8J0CAeWPcCTeYLHx2__AMsqobjeLdOSZTVM1nRBoAN_NfHAraa3Y_mWJXcsOT_XyekWp_GzkR0hbl8INX5HRLa5OQWBLos-WD0vOnBLmZSR0PAGiozlr4lsc_d-kTPo8fegp_BvQM-cPx7mt84EK5Dl9yQ2i7-UHucKxE9upR9G9FKA0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