Rust-GCC / Rust-GCC/gccrs

ICE in lookup_label_temp_var, at rust/backend/rust-compile-expr.cc

Open
#4,611 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
#![feature(no_core)]
#![no_core]

fn main() {
    let x = 'c: loop {
        break 'c 5;
    };
}

original:

#![feature(no_core)]
#![no_core]
// rustfmt-trailing_semicolon: false

#![feature(loop_break_value)]

fn main() {
    'a: loop {
        break 'a
    }

    let mut done = false;
    'b: while !done {
        done = true;
        continue 'b
    }

    let x = loop {
        break 5
    };

    let x = 'c: loop {
        break 'c 5
    };
}

fn foo() -> usize {
    return 0
}

Version information:

696cb485cfa9969c952d6765889d82ed548ca15c

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/696cb485cfa9969c952d6765889d82ed548ca15c/gcc/rust/backend/rust-compile-expr.cc#L2814-L2826

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in lookup_label_temp_var, at rust/backend/rust-compile-expr.cc:2820
0x32c0107 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc7e0b1 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x927f8d Rust::Compile::CompileExpr::lookup_label_temp_var(unsigned int)
	../../gcc/rust/backend/rust-compile-expr.cc:2820
0x927f8d Rust::Compile::CompileExpr::lookup_label_temp_var(unsigned int)
	../../gcc/rust/backend/rust-compile-expr.cc:2814
0x11be4be Rust::Compile::CompileExpr::visit(Rust::HIR::BreakExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:870
0x11b9d86 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:56
0x11afde0 ???
	../../gcc/rust/backend/rust-compile-stmt.h:33
0x11b018c Rust::Compile::CompileStmt::Compile(Rust::HIR::Stmt*, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-stmt.cc:36
0x11cad8b Rust::Compile::CompileBlock::visit(Rust::HIR::BlockExpr&)
	../../gcc/rust/backend/rust-compile-block.cc:55
0x11cb84e Rust::Compile::CompileBlock::compile(Rust::HIR::BlockExpr&, Rust::Compile::Context*, Bvariable*)
	../../gcc/rust/backend/rust-compile-block.cc:36
0x11b8d3d Rust::Compile::CompileExpr::visit(Rust::HIR::LoopExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:792
0x11b9d86 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:56
0x11aff9e Rust::Compile::CompileStmt::visit(Rust::HIR::LetStmt&)
	../../gcc/rust/backend/rust-compile-stmt.cc:74
0x11b018c Rust::Compile::CompileStmt::Compile(Rust::HIR::Stmt*, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-stmt.cc:36
0x11e858b Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*)
	../../gcc/rust/backend/rust-compile-base.cc:681
0x11e9ed3 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:886
0x11ace06 Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	../../gcc/rust/backend/rust-compile-item.cc:235
0xed334b Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
	../../gcc/rust/backend/rust-compile-item.h:37
0xed334b Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:48
0xed334b Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:41
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.mvX4OLoQFu8L/rustc_testrunner_tmpdir_reporting.ILo4ZzXVQUoG/mvce.rs -o/tmp/icemaker_global_tempdir.mvX4OLoQFu8L/rustc_testrunner_tmpdir_reporting.ILo4ZzXVQUoG/binaryname -frust-incomplete-and-experimental-compiler-do-not-use
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

Start by running the reduced lab.rs example with -frust-incomplete-and-experimental-compiler-do-not-use and inspect lookup_label_temp_var in rust/backend/rust-compile-expr.cc around lines 2814-2826. Trace the labeled break through visit(BreakExpr) and confirm the reduced example completes without the internal compiler error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.