Invalid branching in wildcard pattern
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
I tried this code:
enum Foo {
A,
B(i32),
}
fn main() -> i32 {
let result = Foo::B(123);
// { dg-warning "statement will never be executed" "" { target *-*-* } .+1 }
let value = match result {
A => 15,
Foo::B(x) => x,
};
value - 15
}
I expected to see this happen: running this program exits with a 0 exit code.
The "equivalent" Rust code being:
enum Foo {
A,
B(i32),
}
fn main() {
let result = Foo::B(123);
// { dg-error "statement will never be executed" "" { target *-*-* } .+1 }
let value = match result {
A => 15,
Foo::B(x) => x,
};
println!("{}", value - 15)
}
which gives out a lot of warnings but prints zero.
Instead, this happened: the code exited with 108 as a return value, which is 123 - 15
Meta
- What version of Rust GCC were you using: 428a31804b8
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
Run the supplied Rust reproducer with the recorded gccrs revision and compare its exit status with the expected 0. Trace how the compiler handles the match arms and the unqualified variant pattern; done means the reproducer exits 0 while retaining the relevant diagnostics shown in the issue.
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
- 48/100