Skip to content

Crash when switch expression is a constant-valued directionless argument #5313

Open
@kfcripps

Description

@kfcripps

Building the following P4 program with p4test:

void bar(bit<2> x, out bit<8> y) {
    switch (x) {
        0b01: { y = 2; }
        0b10: { y = 3; }
    }
}

control C(out bit<8> y) {
    action foo() {
        bar(1, y);
    }

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

    apply {
        t.apply();
    }
}

control proto(out bit<8> y);
package top(proto p);

top(C()) main;

results in:

tmp.p4(2): [--Wwarn=mismatch] warning: x: constant expression in switch
    switch (x) {
            ^
In file: ../../../frontends/p4/simplifySwitch.cpp:34
Compiler Bug: tmp.p4(2): Unexpected expression x;
    switch (x) {
            ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreTopics concerning the core segments of the compiler (frontend, midend, parser)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions