Rust-GCC / Rust-GCC/gccrs

ICE in find_value_definition, at rust/checks/lints/rust-lint-marklive.cc match guard with unknown enum variant

Open
#4,670 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug missing-lint name resolution
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
pub enum Something {
    Cat(u64),
    Dog(u64),
}

fn main() {
    let my_int: i32 = 1;

    match my_int {
        x if x == Something::Foo as i32 => {}

        _ => {}
    }
}

original:

#[repr(i32)]
pub enum Something {
    Cat(u64),
    Dog(u64),
}

fn main() {
    let my_int: i32 = 1;

    match my_int {
        x if x == Something::Foo as i32 => {}
        //1 => {} // Warning: no value can reach this
        x if x == Something::Foo as i32 => {}
        x if x == Something::Foo as i32 => {} // No warning
        x if x == Something::Foo as i32 => {} // No warning
        x if x == Something::Blarg as i32 => {}
        _ => {}
    }
}

Version information:

206d052f0c25feb613d28fcd71877db7db089c14

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/206d052f0c25feb613d28fcd71877db7db089c14/gcc/rust/checks/lints/rust-lint-marklive.cc#L278-L290

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 find_value_definition, at rust/checks/lints/rust-lint-marklive.cc:284
0x32c99c7 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc7f8e1 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x92516c Rust::Analysis::MarkLive::find_value_definition(unsigned int, unsigned int&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:284
0x925208 Rust::Analysis::MarkLive::find_value_definition(unsigned int, unsigned int&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:124
0x925208 Rust::Analysis::MarkLive::visit(Rust::HIR::PathInExpression&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:120
0x117c776 Rust::Analysis::MarkLive::visit(Rust::HIR::MatchExpr&)
	../../gcc/rust/checks/lints/rust-lint-marklive.h:215
0x117a880 Rust::Analysis::MarkLive::go(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:95
0x117ac24 Rust::Analysis::MarkLive::Analysis(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:75
0xed0977 Rust::Analysis::ScanDeadcode::Scan(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-scan-deadcode.h:45
0xec977c Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:857
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.Uw5XMoCnQ6pG/mvce.rs -o/tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.Uw5XMoCnQ6pG/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

Start with the reduced Rust reproducer and the command shown in the issue, then inspect rust/checks/lints/rust-lint-marklive.cc around lines 278-290, especially find_value_definition. Reproduce the ICE and trace how the match guard references the unknown enum variant. Done means the reduced case no longer triggers an internal compiler error and the relevant compiler behavior is covered by an appropriate test.

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.