C `sizeof(struct)` - bad order of evaluation
Opened this issue · 0 comments
h0nzZik commented
The program
int main() {
return sizeof(struct S{int x;}) + sizeof(struct S);
}
fails to compile, with the error message
empty0.c:2:2: warning: Trying to compute sizeof of an incomplete or function type. (Constraint violation)
However, if we swap the operands of +
, the program compiles (with -fno-native-compilation
):
int main() {
return sizeof(struct S) + sizeof(struct S{int x;});
}
I guess that the problem is that the right side of + is evaluated first. For -
,*
, and /
, the order of evaluation seem to be right.