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

const fn allows unreachable calls to non-const fns #62404

Open
Centril opened this issue Jul 5, 2019 · 3 comments
Open

const fn allows unreachable calls to non-const fns #62404

Centril opened this issue Jul 5, 2019 · 3 comments
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Jul 5, 2019

E.g. the following compiles on stable:

const fn f() {
    return;
    fn f() {}
    f();
}

@eddyb notes that this is because we do a "semantic check" and that f(); is not linked in the CFG.

However, it seems to me that the basic blocks should be there (tho I haven't checked yet...) so you can visit the call to f(); and ban it.

cc @oli-obk

@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jul 5, 2019
@eddyb
Copy link
Member

eddyb commented Jul 5, 2019

Everything is allowed in dead code - control-flow, loops, pointer ops, etc.
@rust-lang/lang might want to discuss it further but IMO this is okay.

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Jul 5, 2019
@Centril
Copy link
Contributor Author

Centril commented Jul 5, 2019

cc #62272 #62274

@Enselic
Copy link
Member

Enselic commented Jul 24, 2023

@rustbot label A-const-fn

@rustbot rustbot added the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants