p4c icon indicating copy to clipboard operation
p4c copied to clipboard

`Compiler Bug` in `simplifySwitch.cpp`

Open kfcripps opened this issue 3 weeks ago • 8 comments

Building the following P4 program:

extern void __e(in bit<28> arg);
extern void __e2(in bit<28> arg);

control C() {
    action bar(bool a, bool b) {
        bit<28> x; bit<28> y;
        switch (a) {
        b: {
                __e(x);
            }
        default: {
            if (b) {
                __e2(y);
            }
            }
        }
    }

    action baz() {
        bar(true, false);
    }

    action foo() {
        baz();
        baz();
    }

    table t {
        actions = { foo; }
        default_action = foo;
    }

    apply {
        t.apply();
    }
}

control proto();
package top(proto p);

top(C()) main;

results in:

In file: p4c/frontends/p4/simplifySwitch.cpp:34
Compiler Bug: t.p4(7): Unexpected expression a;
        switch (a) {
                ^

kfcripps avatar Feb 03 '25 23:02 kfcripps