gccrs
gccrs copied to clipboard
gccrs enters infinite loop/hangs when compiling match patterns with macros or tuple structs
Summary
When compiling code containing match expressions with a macro-expanded tuple struct pattern (ApplicationTy(TypeCtor::X)) or equivalent OR patterns, gccrs fails to terminate and gets killed (SIGKILL). The same code compiles successfully with rustc (only warnings about dead code).
Reproducer
I tried this code:
#![deny(unreachable_patterns)]
pub enum TypeCtor { Slice, Array }
pub struct ApplicationTy(TypeCtor);
macro_rules! ty_app { ($ctor:pat) => { ApplicationTy($ctor) }; }
fn _foo(ty: ApplicationTy) {
match ty { ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {} }
// Expanded version also crashes:
// match ty { ApplicationTy(TypeCtor::Array) | ApplicationTy(TypeCtor::Slice) => {} }
}
fn main() {}
Does the code make use of any (1.49) nightly feature ?
- [ ] Nightly
Godbolt link
https://godbolt.org/z/fT6r9EKso
Actual behavior
Compiler hangs indefinitely and gets terminated with SIGKILL (exit code 143).
Expected behavior
Successful compilation with warnings about unused fields/functions.
GCC Version
14.2