-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
miri_to_const
bug on big-endian targets
#11488
Comments
Ah, in |
Oh, also that code is completely ignoring the |
The scalar floats are also read wrong when cross compiling between big and little endian targets, right? |
Yes, when I said they are wrong on big-endian targets I meant they are wrong whenever the (Having a big-endian host and a little-endian target should work with the current code, though.) |
Note that there were some recent rustc changes here, so if code this is now changed on the clippy side it would probably lead to conflicts. We should await the next rustc-to-clippy sync. |
I was referring to conversion a little above that. ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
int.try_into().expect("invalid f32 bit representation"),
))),
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(
int.try_into().expect("invalid f64 bit representation"),
))), |
That should be fine, |
Description
I just noticed the
miri_to_const
function. This seems to duplicate a bunch of the logic intry_destructure_mir_constant_for_diagnostics
, maybe it would make sense to fully migrate to that query instead?In particular the current logic is partially wrong: it has support for
ConstValue::Indirect
arrays of floats. However, usingfrom_le_bytes
to convert interpreter floats to anf32
is going to go wrong on big-endian targets. You need to take into account the endianess of the current compiler session. Or ideally you just use all the functions that already exist in rustc to work with interpreter data, e.g.Allocation::read_scalar
.(Also, we are using "Miri" as the name for the tool these days, so the function is somewhat misnamed. This is really just converting a MIR constant into a Clippy constant.)
Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered: