Rust-GCC / Rust-GCC/gccrs

ICE in compile_function fn that calls a main() with arguments

Open
#4,669 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
fn foo(f: for<'a, 'b> fn(&'a ()) -> &'a &'b ()) {
    main(f);
}

fn main(f: for<'a, 'b> fn(&'a ()) -> &'a &'b ()) {}

original:

fn foo(f: for<'a,'b> fn(&'a ()) -> &'a &'b ()) {
    main(f);
}

fn bar(f: for<'a,'b> fn(&'b ()) -> &'a &'b ()) {
}

fn main(f: for<'a,'b> fn(&'a ()) -> &'a &'b ()) {
}

Version information:

206d052f0c25feb613d28fcd71877db7db089c14

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/206d052f0c25feb613d28fcd71877db7db089c14/gcc/rust/backend/rust-compile-base.cc#L772-L784

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)

Program output

crab1: internal compiler error: in compile_function, at rust/backend/rust-compile-base.cc:778
0x32c99c7 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc7f8e1 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x92fe17 Rust::Compile::HIRCompileBase::compile_function(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tl::optional<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 long, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const&, Rust::TyTy::FnType*)
	../../gcc/rust/backend/rust-compile-base.cc:778
0x11b41c6 Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	../../gcc/rust/backend/rust-compile-item.cc:235
0xed548b Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
	../../gcc/rust/backend/rust-compile-item.h:37
0xed548b Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:49
0xed548b Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:42
0xec9767 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:851
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.hTgc1cbPBU8d/mvce.rs -o/tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.hTgc1cbPBU8d/binaryname -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the reduced Rust reproducer with the listed flags, then inspect gcc/rust/backend/rust-compile-base.cc:772-784 and the compile_function path shown in the backtrace. Done means this input no longer triggers an internal compiler error and the compiler handles it normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.