关于C标准中->运算符第一个操作数是否需指向完整结构体的技术问询
关于C标准中->运算符第一个操作数是否需指向完整结构体的技术问询
各位深耕C语言标准的大佬们,想请教一个关于C23标准里->运算符的细节问题:
先看这段代码:
struct s { int x; int y[sizeof((struct s*)0)->x]; };
C23标准的6.5.3.4p2条款给出了如下约束:
The first operand of the -> operator shall have type "pointer to atomic, qualified, or unqualified structure" or "pointer to atomic, qualified, or unqualified union", and the second operand shall name a member of the type pointed to.
我翻遍这段约束,都没看到要求->的第一个操作数必须指向完整的结构体类型的规定——那上面这段代码在C23标准框架下是合法的吗?
备注:内容来源于stack exchange,提问作者pmor
相关产品推荐
相关产品推荐

