Skip to content

ppci-cc: cannot compile combined struct assignment #108

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C frontendIssues related to the C language compilerbug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions