Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive function causes undefined behavior in release mode #80301

Closed
Mokuzzai opened this issue Dec 22, 2020 · 1 comment
Closed

Recursive function causes undefined behavior in release mode #80301

Mokuzzai opened this issue Dec 22, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@Mokuzzai
Copy link

Mokuzzai commented Dec 22, 2020

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.

@Mokuzzai Mokuzzai added the C-bug Category: This is a bug. label Dec 22, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #28728

@jonas-schievink jonas-schievink marked this as a duplicate of #28728 Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants