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

Tuple pattern as function parameter causes internal compiler error #2847

Open
0xn4utilus opened this issue Feb 12, 2024 · 3 comments
Open

Tuple pattern as function parameter causes internal compiler error #2847

0xn4utilus opened this issue Feb 12, 2024 · 3 comments

Comments

@0xn4utilus
Copy link
Contributor

I tried this code: https://godbolt.org/z/vTPqxfeMa

fn myfun((x, _): (i32, i32)) -> i32 {
   x
}

I expected it to compile correctly and just throw warning function myfun is never used.

But instead it caused internal compiler error.

@0xn4utilus 0xn4utilus added the bug label Feb 12, 2024
@0xn4utilus
Copy link
Contributor Author

Trying out different irrefutable patterns as parameters, will comment if any other pattern causes error.

@0xn4utilus
Copy link
Contributor Author

While investigating this bug, I tried out this: https://godbolt.org/z/3s398sW1r

The below code compiles correctly.

fn myfun() -> i32 {
    let (x, a) =  (1, 2);
    x
}

This causes internal compiler error.

fn myfun() -> i32 {
    let (x, _) =  (1, 2);
    x
}

@CohenArthur
Copy link
Member

ICE backtrace:

crab1: internal compiler error: in function_set_parameters, at rust/rust-gcc.cc:2284
0x236722c internal_error(char const*, ...)
	???:0
0x9fc228 fancy_abort(char const*, int, char const*)
	???:0
0xd8e28d 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
0xd64d3a Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	???:0
0xb3c829 Rust::Compile::CompileCrate::go()
	???:0
0xb3c8a8 Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	???:0
0xb37b7c 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

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

No branches or pull requests

2 participants