Skip to content

Compiler bug with switch fall through at the end (and no other statements) #3619

Closed
@apinski-cavium

Description

Take:

control c(in bit<4> v)
{
  apply{
    switch(v) {
      default:
    }
  }
}

We get a warning like we should but then a compiler bug happens:

testsuite/p4c.language/valid/control/bitswitch-1.p4(6): [--Wwarn=missing] warning: SwitchCase: fallthrough with no statement
      default:
      ^^^^^^^
In file: /home/apinski/src/p4/p4c/frontends/p4/simplify.cpp:99
Compiler Bug: testsuite/p4c.language/valid/control/bitswitch-1.p4(4): v;: expected a Member
    switch(v) {
           ^

Yes the above code should not really appear in real code, I was just writing testcases for my front-end to make sure I did not mess it up and happened upon the crash here.

Metadata

Assignees

Labels

bugThis behavior is unintended and should be fixed.fixedThis topic is considered to be fixed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions