Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure on switch statement with non-block substatement #520

Open
dkolsen-pgi opened this issue Mar 24, 2024 · 1 comment · May be fixed by #528
Open

Assertion failure on switch statement with non-block substatement #520

dkolsen-pgi opened this issue Mar 24, 2024 · 1 comment · May be fixed by #528

Comments

@dkolsen-pgi
Copy link
Collaborator

ClangIR hits an assertion failure when a switch statement has a non-block statement as its substatement.

int f(int x) {
  switch (x)
  case 1:
    return -1;
  return x;
}
clang++: .../clang/lib/CIR/CodeGen/CIRGenStmt.cpp:964: 
cir::CIRGenFunction::buildSwitchStmt(const clang::SwitchStmt&)::<lambda()>::<lambda(mlir::OpBuilder&, mlir::Location, mlir::OperationState&)>: 
Assertion `cs && "expected compound stmt"' failed.

While code like this should never appear in production and will only ever be found in test suites that try to break the compiler, it is legal code in both C and C++ and should not trigger an internal compiler error.

@dkolsen-pgi dkolsen-pgi changed the title Switch statement with non-block substatement Assertion failure on switch statement with non-block substatement Mar 24, 2024
@wenpen
Copy link
Contributor

wenpen commented Apr 1, 2024

I'd like to work on this, it looks like I only need to add some logic to handle CaseStmt and DefaultStmt.

@wenpen wenpen linked a pull request Apr 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants