Rust-GCC / Rust-GCC/gccrs

NR2: ICE in visit, at rust/hir/rust-ast-lower-expr.cc:594 lowering for loop

Open
#3,673 3 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-name-resolution-2.0
pub struct TreeBuilder<H> {
    pub h: H,
}

impl<H> TreeBuilder<H> {
    pub fn process_token(&mut self) {
        match self {
            _ => for _y in self.by_ref() {},
        }
    }
}

original:

#![crate_type = "lib"]

pub struct TreeBuilder<H> { pub h: H }

impl<H> TreeBuilder<H> {
    pub fn process_token(&mut self) {
        match self {
            _ => for _y in self.by_ref() {}
        }
    }
}

impl<H> TreeBuilder<H> {
    pub fn process_token(&mut self) {
        match self {
            _ => for _y in self.by_ref() {}
        }
    }
}

Version information:

765121736dfe3f5b319bbe9837880deda326394e

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/765121736dfe3f5b319bbe9837880deda326394e/gcc/rust/hir/rust-ast-lower-expr.cc#L588-L600

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

Program output

crab1: internal compiler error: in visit, at rust/hir/rust-ast-lower-expr.cc:594
0x88ce86 Rust::HIR::ASTLoweringExpr::visit(Rust::AST::ForLoopExpr&)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:594
0xe87322 Rust::HIR::ASTLoweringExpr::translate(Rust::AST::Expr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:43
0xe5d4a4 Rust::HIR::ASTLoweringExprWithBlock::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:434
0xe7e908 Rust::HIR::ASTLoweringExprWithBlock::translate(Rust::AST::ExprWithBlock&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:153
0xe7e908 Rust::HIR::ASTLoweringExpr::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:689
0xe87322 Rust::HIR::ASTLoweringExpr::translate(Rust::AST::Expr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:43
0xe5c186 Rust::HIR::ASTLoweringBlock::visit(Rust::AST::BlockExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:141
0xe7d4c3 Rust::HIR::ASTLoweringBlock::translate(Rust::AST::BlockExpr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:37
0xe7d4c3 Rust::HIR::ASTLowerImplItem::visit(Rust::AST::Function&)
	../../gcc/rust/hir/rust-ast-lower-implitem.cc:170
0xe7e509 Rust::HIR::ASTLowerImplItem::translate(Rust::AST::AssociatedItem&, unsigned int)
	../../gcc/rust/hir/rust-ast-lower-implitem.cc:34
0xe74ec3 Rust::HIR::ASTLoweringItem::visit(Rust::AST::InherentImpl&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:534
0xe6f11e Rust::HIR::ASTLoweringItem::translate(Rust::AST::Item&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:38
0xe5cba7 Rust::HIR::ASTLowering::go()
	../../gcc/rust/hir/rust-ast-lower.cc:81
0xe5d0a1 Rust::HIR::ASTLowering::Resolve(Rust::AST::Crate&)
	../../gcc/rust/hir/rust-ast-lower.cc:71
0xce8eb8 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:663
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 with the reduced Rust reproducer and command shown in the issue, then inspect gcc/rust/hir/rust-ast-lower-expr.cc around lines 588-600, especially ASTLoweringExpr::visit(ForLoopExpr). Trace the lowering path from the match expression to the for loop and verify that the reduced program no longer produces the internal compiler error.

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
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.