Rust-GCC / Rust-GCC/gccrs

ICE in in translate, at rust/hir/rust-ast-lower-pattern.cc:35 , match on byte lit

Open
#3,633 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
fn main() {
    match "food".as_bytes() {
        &[b'f', ..] => (),
    }
}

original:

// run-pass

// Test that we do not ICE when pattern matching an array against a slice.

fn main() {
    match "food".as_bytes() {
        b"food" => (),
        &[b'f', ..] => (),
        b"food" => ()
    }
}

Version information:

765121736dfe3f5b319bbe9837880deda326394e

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

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 translate, at rust/hir/rust-ast-lower-pattern.cc:35
0x866961 Rust::HIR::ASTLoweringPattern::translate(Rust::AST::Pattern&, bool)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:35
0xddd06b Rust::HIR::ASTLoweringPattern::visit(Rust::AST::SlicePattern&)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:314
0xddc804 Rust::HIR::ASTLoweringPattern::translate(Rust::AST::Pattern&, bool)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:33
0xddc8c5 Rust::HIR::ASTLoweringPattern::visit(Rust::AST::ReferencePattern&)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:288
0xddf006 Rust::HIR::ASTLoweringPattern::translate(Rust::AST::Pattern&, bool)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:33
0xdd07ee Rust::HIR::ASTLoweringExprWithBlock::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:446
0xdf1bc8 Rust::HIR::ASTLoweringExprWithBlock::translate(Rust::AST::ExprWithBlock&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:153
0xdf1bc8 Rust::HIR::ASTLoweringExpr::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:689
0xdfa5e2 Rust::HIR::ASTLoweringExpr::translate(Rust::AST::Expr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:43
0xdcf446 Rust::HIR::ASTLoweringBlock::visit(Rust::AST::BlockExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:141
0xde16aa Rust::HIR::ASTLoweringBlock::translate(Rust::AST::BlockExpr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:37
0xde16aa Rust::HIR::ASTLoweringItem::visit(Rust::AST::Function&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:444
0xde23de Rust::HIR::ASTLoweringItem::translate(Rust::AST::Item&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:38
0xdcfe67 Rust::HIR::ASTLowering::go()
	../../gcc/rust/hir/rust-ast-lower.cc:81
0xdd0361 Rust::HIR::ASTLowering::Resolve(Rust::AST::Crate&)
	../../gcc/rust/hir/rust-ast-lower.cc:71
0xc5c258 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

Run the reduced Rust reproducer with -frust-incomplete-and-experimental-compiler-do-not-use to confirm the ICE. Read gcc/rust/hir/rust-ast-lower-pattern.cc around lines 29-41, along with the SlicePattern and ReferencePattern paths identified in the backtrace. Done means the match on a byte slice compiles without an 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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.