-
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
no warning for div by zero: let x = 1 / false as u8; #49760
Comments
It warns on current stable, but not on beta and nightly. Might be miri fallout? cc @oli-obk Curiously, when you take a reference (to trigger promotion to static) you get a hard error on beta and nightly (stable is still a warning). Isn't that a regression? |
triage: P-medium Still want to get those warnings, but no longer P-high |
Hm, what is the status of this? The PR was merged, but with For the second one I get two though? 😕
|
The PR was just for the compilation error. The missing warnings just need an impl for this branch: https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/const_prop.rs#L236 The warning duplication is unfortunate, but if we deduplicate it, we loose warnings in other edge cases. We could deduplicate it similar to the way the notes about where the lint level was set are deduplicated (note how the second warning has no |
Const propagate casts fixes #49760 So... This fixes the original issue about the missing warnings. But our test suite contains fun things like ```rust fn foo() {} assert_eq!(foo as i16, foo as usize as i16); ``` Which, will result in > a raw memory access tried to access part of a pointer value as raw bytes on both sides of the assertion. Because well... that's exactly what's going on! We're ripping out 16 bits of a pointer.
inlined inside a
println!()
, I get a warning:however, when I involve a variable
there is no warning at all but looking at the generated code it is quite clear that this panics:
https://godbolt.org/g/NQmSFM
The text was updated successfully, but these errors were encountered: