Skip to content

The compiler does not report errors for recursive calls that can not be ended #128217

New issue

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

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

Already on GitHub? # to your account

Closed
hacbit opened this issue Jul 26, 2024 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hacbit
Copy link

hacbit commented Jul 26, 2024

Code

fn foo() {
    bar()
}
fn bar() {
    foo()
}
fn main() {
    foo()
}

Current output

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

Desired output

It shouldn't pass compilation :(

Rationale and extra context

I think the compiler should detect recursive calls that can't end and report an error, rather than exiting at runtime due to a stack overflow. btw, I tried checking with cargo clippy but didn't detect the issue

Other cases

No response

Rust Version

rustc 1.81.0-nightly (3cf924b93 2024-06-15)
binary: rustc
commit-hash: 3cf924b934322fd7b514600a7dc84fc517515346
commit-date: 2024-06-15
host: x86_64-pc-windows-msvc
release: 1.81.0-nightly
LLVM version: 18.1.7

Anything else?

No response

@hacbit hacbit added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 26, 2024
@asquared31415
Copy link
Contributor

Duplicate of #57965
It is known that indirect recursion (anything not directly calling itself) is not detected at this time.

@hacbit
Copy link
Author

hacbit commented Jul 26, 2024

Duplicate of #57965 It is known that indirect recursion (anything not directly calling itself) is not detected at this time.

thanks, i get it.

@hacbit hacbit closed this as completed Jul 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants