gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

GCCRS fails to compile deeply nested macro_rules! expansions, exits with SIGKILL

Open starbugs-qurong opened this issue 8 months ago • 0 comments

Summary

When compiling code with deeply nested macro_rules! expansions (e.g., x10!{x10!{x10!{...}}}), GCCRS consumes excessive resources and gets killed by the OS (SIGKILL), while Rustc handles it gracefully.

Reproducer

I tried this code:

fn get_pair(_a: &mut u32, _b: &mut u32) {}

macro_rules! x10 {
    ($($t:tt)*) => {
        $($t)* $($t)* $($t)* $($t)* $($t)*
        $($t)* $($t)* $($t)* $($t)* $($t)*
    }
}

#[allow(unused_assignments)]
fn main() {
    let mut x = 1;

    get_pair(&mut x, &mut x);
    //~^ ERROR: cannot borrow `x` as mutable more than once at a time

    x10! { x10!{ x10!{ if x > 0 { x += 2 } else { x += 1 } } } }
}

Does the code make use of any (1.49) nightly feature ?

  • [ ] Nightly

Godbolt link

https://godbolt.org/z/nn193r3a8

Actual behavior

GCCRS process is terminated with Killed - processing time exceeded.

Expected behavior

A clear error message.

GCC Version

14.2

starbugs-qurong avatar Apr 10 '25 08:04 starbugs-qurong