Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppci-cc: cannot compile combined struct assignment #108

Open
tstreiff opened this issue Jul 8, 2020 · 0 comments
Open

ppci-cc: cannot compile combined struct assignment #108

tstreiff opened this issue Jul 8, 2020 · 0 comments
Labels
bug C frontend Issues related to the C language compiler

Comments

@tstreiff
Copy link
Contributor

tstreiff commented Jul 8, 2020

#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.

@windelbouwman windelbouwman added bug C frontend Issues related to the C language compiler labels Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C frontend Issues related to the C language compiler
Projects
None yet
Development

No branches or pull requests

2 participants