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

    <tr>
        <th>Summary</th>
        <td>
            Taking the address of an expression of type void, and warning about such
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          pascal-cuoq
      </td>
    </tr>
</table>

<pre>
    The following C program, when compiled with Clang 15 with `-pedantic`, [causes](https://gcc.godbolt.org/z/he14hGMqo) the following warnings.
```c
void *p;

void *g(void) {
  return &(p[0]);
}
```
The warnings:
```
<source>:4:13: warning: subscript of a pointer to void is a GNU extension [-Wgnu-pointer-arith]
 return &(p[0]);
           ~^
<source>:4:10: warning: ISO C forbids taking the address of an expression of type 'void' [-Wpedantic]
  return &(p[0]);
         ^ ~~~~
```
The second warning says, without a clause number, that ISO C forbids taking the address of an expression of type 'void'. If this is true, then Clang should reject the following C program when `-pedantic -pedantic-errors -std=c17` are set:
```c
void *p;

void *g(void) {
  return &(*p);
}
```
In this case Clang 15 [compiles without warning](https://gcc.godbolt.org/z/njYW7jo7c).

I don't think that ISO C forbids taking the address of an expression of type 'void' (and if I'm right, this Clang warning should not exist). But if ISO C does forbid taking the address of an expression of type 'void', then the second example should result in a warning when compiled with `-pedantic -pedantic-errors -std=c17`.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslU1z4jgTxz9Nc-mCsiW_wMEHAmGKw_PsYWdrao-y1NjKGMkjyUOyBz77lmwCSXamdrIViiokrJdf9__fbeG9bgxRBfkd5NuZGEJrXdULL0U3l4P9Nquteqo-t4QH23X2pE2DG-ydbZw4AtvgqSWD0h573ZHCkw4tbjphGkzzaQZFMu9JCRO0hCKJeyC_k2Lw5CHfAlu2IfQe-BrYDtiukXLRWFXbLiysa4Dt_gK2aynN2k__-2aBrTC8wjkJZ7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