Skip to content

Recursive function causes undefined behavior in release mode #80301

@Mokuzzai

Description

@Mokuzzai

In latest rust stable, nightly and beta (tried this in playground) this code causes undefined behavior.

// danger!
fn never() -> String {
    never()
}

fn main() {
    let v = never();
    
    println!("{:?}", v);
}

In debug mode this simply causes a stack overflow, but with optimization on it returns an uninitialized value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions