C 2011 (draft N1570) 6.3.2.1 3 says:
Except when it is the operand of the sizeof operator, the _Alignof operator, or the unary & operator, or is a string literal used to initialize an array, an expression that has type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points to the initial element of the array object and is not an lvalue. If the array object has register storage class, the behavior is undefined.
C 2018 6.3.2.1 3 says:
Except when it is the operand of the sizeof operator, or the unary & operator, or is a string literal used to initialize an array, an expression that has type "array of type" is converted to an expression with type "pointer to type" that points to the initial element of the array object and is not an lvalue. If the array object has register storage class, the behavior is undefined.
Why is _Alignof
missing from the latter?
C 2018 Foreward 7 says:
There are no major changes in this edition, only technical corrections and clarifications.
This implies there was something incorrect about exempting _Alignof
from the array conversion rule, causing it to be removed. However, it should be possible to apply _Alignof
to arrays, as C 2018 6.5.3.4 3 says:
The _Alignof operator yields the alignment requirement of its operand type. The operand is not evaluated and the result is an integer constant. When applied to an array type, the result is the alignment requirement of the element type.