#include <assert.h>
struct S { int a; } s1, s2, s3;
int main() {
// simple struct assignment
s1.a = 100;
assert(s1.a == 100);
s2 = s1; // works
assert(s2.a == 100);
// combined struct assignment
s1.a = 200;
assert(s1.a == 200);
s3 = s2 = s1; // compiler exception, AssertionError
assert(s2.a == 200);
assert(s3.a == 200);
return 0;
}
The compiler raises the following exception:
File "/home/tsf/sandbox/ppci/ppci/lang/c/codegenerator.py", line 1032, in gen_expr
assert expr.lvalue
AssertionError
Note that if "struct" is replaced by "union", it works.
The compiler raises the following exception:
Note that if "struct" is replaced by "union", it works.