-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ICE when const evaluating UB #64506
Comments
Interesting. ICEs in Miri with Do you have a backtrace? Which code is responsible for ICEing here and how hard/bad would it be to just error instead? |
It's ICEing in rust/src/librustc_mir/interpret/place.rs Line 387 in 64c0969
! .
|
TBH this looks like a bug to me. That's the layout of which type, Cc @eddyb |
It's not a bug. Just like |
Precisely by analogy with So, correspondingly, |
oh... right. Yea we should totally fix that |
This being a layout bug would trivially break codegen, why is only miri affected? |
Codegen might skip the field access because the type is uninhabited? |
I wouldn't be so sure, codegen calls Can the ICE print the whole EDIT: oh this might be why: we don't check the index at all: rust/src/librustc_target/abi/mod.rs Line 741 in 42ec683
|
yea but we can't use |
You can literally remove the assert to get the same effect. But if the field count is wrong I'd rather have an assert in both places and fix the count (if possible). |
The full
and so far I haven't figured out how that can happen |
Ah, nevermind, I found it: rust/src/librustc/ty/layout.rs Line 830 in 64f61c7
|
Ah so that's a micro-optimization. Maybe we should compute the right thing. |
#64987 computes the layout for structs but keeps returning the never layout for enums without inhabited variants |
…=eddyb Compute the layout of uninhabited structs fixes rust-lang#64506 r? @eddyb
This ICEs on stable, probably since March 2018, but it requires the user to do UB in constants, so...
I think a possible fix would be to enable validation in const eval (cc @RalfJung ), though we should benchmark the perf considerations around that first. Alternatively we can just not ICE here and instead emit an error.
(Playground)
Errors:
The text was updated successfully, but these errors were encountered: