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

Union pattern matching causes ICE #3108

Open
tamaroning opened this issue Jul 30, 2024 · 4 comments
Open

Union pattern matching causes ICE #3108

tamaroning opened this issue Jul 30, 2024 · 4 comments
Labels

Comments

@tamaroning
Copy link
Contributor

https://godbolt.org/z/3bxKGWver

Code

union MyUnion {
    f1: u32,
}

fn f(u: MyUnion) -> i32 {
    unsafe {
        match u {
            MyUnion { f1: 10 } => { 0 }
            _ => { 1 }
        }
    }
}

pub fn main() {}

Meta

  • What version of Rust GCC were you using, git sha if possible.

Error output

Expect to compile successfully but got ICE:

crab1: internal compiler error: in visit, at rust/backend/rust-compile-pattern.cc:563
0x278bc0c internal_error(char const*, ...)
	???:0
0xadc501 fancy_abort(char const*, int, char const*)
	???:0
0xe86535 Rust::Compile::CompilePatternBindings::visit(Rust::HIR::StructPattern&)
	???:0
0xe94c02 Rust::Compile::CompileExpr::visit(Rust::HIR::MatchExpr&)
	???:0
0xe8f5a4 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr*, Rust::Compile::Context*)
	???:0
0xe9e156 Rust::Compile::CompileBlock::visit(Rust::HIR::BlockExpr&)
	???:0
0xe9e3fd Rust::Compile::CompileBlock::compile(Rust::HIR::BlockExpr*, Rust::Compile::Context*, Bvariable*)
	???:0
0xe9144f Rust::Compile::CompileExpr::visit(Rust::HIR::BlockExpr&)
	???:0
0xe8f5a4 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr*, Rust::Compile::Context*)
	???:0
0xeb3694 Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*)
	???:0
0xeb6269 Rust::Compile::HIRCompileBase::compile_function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Rust::HIR::SelfParam&, std::vector<Rust::HIR::FunctionParam, std::allocator<Rust::HIR::FunctionParam> >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >&, unsigned int, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const&, Rust::TyTy::FnType*)
	???:0
0xe8c328 Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	???:0
0xc374f9 Rust::Compile::CompileCrate::go()
	???:0
0xc37578 Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	???:0
0xc31914 Rust::Session::compile_crate(char const*)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
...
Backtrace

crab1: internal compiler error: in visit, at rust/backend/rust-compile-pattern.cc:563
0x278bc0c internal_error(char const*, ...)
  ???:0
0xadc501 fancy_abort(char const*, int, char const*)
  ???:0
0xe86535 Rust::Compile::CompilePatternBindings::visit(Rust::HIR::StructPattern&)
  ???:0
0xe94c02 Rust::Compile::CompileExpr::visit(Rust::HIR::MatchExpr&)
  ???:0
0xe8f5a4 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr*, Rust::Compile::Context*)
  ???:0
0xe9e156 Rust::Compile::CompileBlock::visit(Rust::HIR::BlockExpr&)
  ???:0
0xe9e3fd Rust::Compile::CompileBlock::compile(Rust::HIR::BlockExpr*, Rust::Compile::Context*, Bvariable*)
  ???:0
0xe9144f Rust::Compile::CompileExpr::visit(Rust::HIR::BlockExpr&)
  ???:0
0xe8f5a4 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr*, Rust::Compile::Context*)
  ???:0
0xeb3694 Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*)
  ???:0
0xeb6269 Rust::Compile::HIRCompileBase::compile_function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Rust::HIR::SelfParam&, std::vector<Rust::HIR::FunctionParam, std::allocator<Rust::HIR::FunctionParam> >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >&, unsigned int, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const&, Rust::TyTy::FnType*)
  ???:0
0xe8c328 Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
  ???:0
0xc374f9 Rust::Compile::CompileCrate::go()
  ???:0
0xc37578 Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
  ???:0
0xc31914 Rust::Session::compile_crate(char const*)
  ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

@tamaroning tamaroning added the bug label Jul 30, 2024
@tamaroning
Copy link
Contributor Author

Can someone assign this issue and #3070 to me?

@tamaroning
Copy link
Contributor Author

Similar case which causes ICE
https://godbolt.org/z/5fKb44T5a

@liamnaddell
Copy link
Contributor

@tamaroning , one thing I've done to make sure efforts aren't duplicated is to create draft commits with the issue tagged in the title, that makes it so that whenever you push, it puts a message onto the issue saying that I'm working on it. EX: #3045

@tamaroning
Copy link
Contributor Author

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants