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

    <tr>
        <th>Summary</th>
        <td>
            Clang x86-64: _Alignof(void(void)) should probably evaluate to 1 for GCC compatibility, or be rejected
        </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>
    In C, `_Alignof(void(void))` is a constraint violation: “The _Alignof operator shall not be applied to a function type or an incomplete type” in https://cigix.me/c17#6.5.3.4.p1

GCC accepts function types in `_Alignof`. And apart from that, in GCC and, according to the arguments presented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023 , in any compliant C compiler, for an object type `t`, `_Alignof(t)` is the minimal alignment imposed by the ABI, not the alignment that the compiler happens to enforce for its own definitions in the compilation unit that contains the `_Alignof(t)`.

For consistency, and although `_Alignof(void(void))` is outside the C standard, if it is accepted at all in Clang, `_Alignof(void(void))` should evaluate to `1` on x86-64, the way it does with GCC.

Compiler Explorer link: https://gcc.godbolt.org/z/3rTrnsa8f

Test program:
```
int align_function;

void f(void)
{
  align_function = _Alignof(void(void));
}
```

Compiled with x86-64 Clang 16.0 -O2:
```
f:                                      # @f
        movl    $4, align_function(%rip)
        retq
```

Compiled with x86-64 GCC 12.2:
```
f:
        movl    $1, align_function(%rip)
        ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1z4ygQ_TX40hWVhGRZPvjg2OOtOe0l9xSCltS7CDSAknh-_RTIztdkUhmXyvqAbt57_RqE99QbxB1b37L1cSXmMFi3m4SXQt_I2f5YtVadd98NHBg_AKvz-72m3tiO8ebBknq-beNV50AeBEhrfHCCTIAHsloEsoaVe2DfOGtytj3cDQjXTGAndCJYB34QWoOxAVoEMU2aUEGwIKCbjYxJ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