NR2: ICE when trying to compile enums with non-const discriminants.
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
Related Issue
https://github.com/Rust-GCC/gccrs/issues/3635
Code
fn main() {
let y = 3;
enum Foo {
Bar = y,
// { dg-error "cannot find value .y. in this scope" "" { target *-*-* } .-1 }
}
}
Error output
test.rs:4:11: error: cannot find value 'y' in this scope [E0425]
4 | Bar = y,
| ^
crab1: internal compiler error: Segmentation fault
0x12fcf03 crash_signal
../../gccrs/gcc/toplev.cc:319
0xb7cc00 Rust::TyTy::VariantDef::as_string[abi:cxx11]() const
../../gccrs/gcc/rust/typecheck/rust-tyty.cc:1541
0xb7cf6b Rust::TyTy::ADTType::as_string[abi:cxx11]() const
../../gccrs/gcc/rust/typecheck/rust-tyty.cc:1677
0xb9958b Rust::TyTy::VarianceAnalysis::GenericTyVisitorCtx::process_type(Rust::TyTy::ADTType&)
../../gccrs/gcc/rust/typecheck/rust-tyty-variance-analysis.cc:236
0xb997b3 Rust::TyTy::VarianceAnalysis::GenericTyPerCrateCtx::process_type(Rust::TyTy::ADTType&)
../../gccrs/gcc/rust/typecheck/rust-tyty-variance-analysis.cc:131
0xbb8ff7 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Enum&)
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:391
0xbb3d5b Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0xbb3d5b Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:45
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the minimal Rust program and trace the enum handling through gcc/rust/typecheck/rust-tyty.cc and gcc/rust/typecheck/rust-tyty-variance-analysis.cc, especially VariantDef::as_string and the variance-analysis visitors. Done means the invalid discriminant still reports E0425 without causing an internal compiler error or segmentation fault.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100