为什么 5[a] 有效并且不会产生无效标识符的错误?

Why is 5[a] valid and does not generate an error of invalid identifier?

With arrays, why is it the case that a[5] == 5[a]?中解释说a[5]中的[]运算符被定义为*(a + 5)并且因为+是可交换的,5[a] 表示 *(5 + a) 等两个表达式引用相同的内存位置。很好

但是C在6.4.2.1中也定义了标识符不能以数字开头。在 5[a] 中,数组标识符是 5,这不是有效标识符。为什么 5[a] 不生成关于无效标识符的错误?

5 不是标识符,它是整数文字。

C 标准字面意思是 5[a] 只是语法糖, 必须 等同于 *(5 + a)。 C 中没有要求 + 运算符的第一个操作数是标识符,因此代码可以正常工作。

6.5.6,强调我的:

For addition, either both operands shall have arithmetic type, or one operand shall be a pointer to a complete object type and the other shall have integer type.