Skip to content

the recursive limit doesn't work with println! and other macros #41731

Closed
@gdepoire

Description

@gdepoire

This code makes the compiler crash with a stack overflow (tested on the playground):

fn main() {
    macro_rules! stack {
        ($overflow:expr) => {
            println!(stack!($overflow));
        };
    }
    
    stack!("overflow");
}

You can try this code on the playground.

If you replace the println! by a print!, the compiler will crash with a segmentation fault instead.
You can try this on the playground too.

The compiler doesn't detect the recursive macro. In fact, it only detect them if we remove the println!.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions