-
Notifications
You must be signed in to change notification settings - Fork 385
argument-less const fn
do not get properly executed
#1081
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
Comments
const fn
do not get properly executedconst fn
do not get properly executed
cc @Centril wrt side effects in const fn. My stance is that it's UB to do side effects in const fn |
Well right now, with "Miri unleashed", this bug means we miss UB. So whatever your stance is, we have to change something. If you don't like my proposal of restricting memoization to CTFE, please make another one. |
I agree with that, at least until we say otherwise. :) |
Given that Miri is all about detecting UB I don't see how that argument helps here at all? The discussion of how to expand UB to incorporate |
My interpretation is that that PR landed because nobody realized that this would affect Miri as well, and we should revert its Miri effect ASAP before doing anything else. Then we can talk about expanding our UB and making Miri check it or whatever. Is that not correct? If Miri behavior was deliberately changed by that PR I am surprised I did not get Cc'd. I'd prefer to be in the loop for such things. |
Sorry, I keep forgetting this. Not sure how to fix that except remind myself regularly of it. I'll strive to do better.
I now see that I did not realize
The change is actually a language change now, because it only looks at the result of a const eval and not at the intermediate computation. For const eval that's not a problem, so I'll make a PR allowing miri to still run the function |
A language change in Miri, you mean? Yes, that's why I raised this issue.
Thanks! |
No, but in the future MIR optimizations may optimize out such function calls and just put their result into the MIR |
That is a language change requiring some new UB though (at least when considering Rust with Miri unleashed) -- so I hope we don't do this before we can detect such UB. |
Fixed by rust-lang/rust#66866 |
With rust-lang/rust#66294 landed, argument-less
const fn
get memoized even when run in Miri. I am pretty sure that is wrong as they can (certainly through unsafe code, once that is allowed) have arbitrary side-effects.Cc @davidhewitt @oli-obk
The text was updated successfully, but these errors were encountered: