-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Array indexed by enum cast to usize no longer has bounds check eliminated #102303
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
Comments
@rustbot label +T-compiler +A-codegen +I-slow |
Regressed in #96862 |
@Dajamante is working on it |
Note that this still works: pub fn func(inbounds: &Enum, array: &[i16; 3]) -> i16 {
array[*inbounds as usize]
} So this is also the classic "LLVM doesn't have range metadata on parameters" problem. (When there's a load, it gets EDIT: Filed #102389 to discuss with lang whether that should compile. It didn't used to. |
Should that work?
But I don't see why a change in drop behavior should affect whether a value is moved or not, and of course, there is no warning. |
Example of the specific behavior with IR and using the load "workaround" https://godbolt.org/z/YK79ErY5r |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
@rustbot claim |
Uh oh!
There was an error while loading. Please reload this page.
Rust compiler fails to eliminate bounds check when array is indexed by an enum cast to usize
Compiler explorer: https://godbolt.org/z/4o5cqT1eK
Code
I expected the compiler to remove the bounds checks like it did previously however it failed to do so.
Version it worked on
It most recently worked on: Rust 1.63.0
Version with regression
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
The text was updated successfully, but these errors were encountered: