-
Couldn't load subscription status.
- Fork 13.9k
Open
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullC-bugCategory: This is a bug.Category: This is a bug.
Description
Consider this code:
fn main() { let a = (); let b = (); dbg!(std::ptr::eq(&a, &b)); }It will output false in debug build, but true in release build.
I've tried other Zero-Sized Types (ZST), like an empty array and a struct with no field, and the result is still the same.
Interestingly, the code below will consistently output false in both debug build and release build:
fn main() { let a = (); let b = (); dbg!((&a as *const _) == (&b as *const _)); }Meta
rustc --version --verbose:
rustc 1.51.0 (2fd73fabe 2021-03-23) binary: rustc commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0 commit-date: 2021-03-23 host: x86_64-apple-darwin release: 1.51.0 LLVM version: 11.0.1 (Rust 1.51, 1.53, and nightly (2021-07-25) have this behavior.)
hellow554 and ZippeyKeys12
Metadata
Metadata
Assignees
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullC-bugCategory: This is a bug.Category: This is a bug.