Closed
Description
I tried this code:
struct U16(u16);
impl Drop for U16 {
fn drop(&mut self) {
println!("{:p}", self);
}
}
struct HasDrop;
impl Drop for HasDrop {
fn drop(&mut self) {}
}
#[repr(packed)]
struct Misalign(u8, Wrapper);
struct Wrapper {
_a: U16,
b: HasDrop,
}
fn main() {
let m = Misalign(
0,
Wrapper {
_a: U16(10),
b: HasDrop,
},
);
let _x = m.1.b;
}
I expected to see this happen: The reference is aligned
Instead, this happened:
$ rustc +nightly -Copt-level=3 test.rs
$ ./test
0x7ffc5e1dad79
Meta
rustc --version --verbose
:
rustc 1.64.0-nightly (2643b1646 2022-07-27)
binary: rustc
commit-hash: 2643b16468fda787470340890212591d8bc832b7
commit-date: 2022-07-27
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
@rustbot label I-unsound A-mir
Metadata
Metadata
Assignees
Labels
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlCategory: This is a bug.Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityUntriaged performance or correctness regression.