Skip to content

Compiler Bug when for loop iterates over tuple type #5481

@kfcripps

Description

@kfcripps
extern void foo(in bit<8> arg);

control C() {
    action a() {
        for (bit<8> i in tuple<bit<8>> { 1 }) {
            foo(i);
        }
    }

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

    apply {
        t.apply();
    }
}

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

top(C()) main;

Results in:

$ p4test --dump tmp tmp.p4
terminate called after throwing an instance of 'P4::Util::CompilerBug'
  what():  In file: ir/ir-generated.cpp:4873
Compiler Bug: ir/ir-generated.cpp:4873: Null arguments

I encounter the same assertion when the forCollectionExpr is a typeRef, for example:

header h_t { bit<8> f; }
...
        for (bit<8> i in h_t) {
            foo(i);
        }

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