Union pattern matching causes ICE
Open
@tamaroning is already working on this.
Since Sep 11, 2024.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.