2018-09-15 10:12:48 -05:00
|
|
|
fn main() {
|
|
|
|
let b = Box::new(0);
|
|
|
|
let x = &*b as *const i32; // soon-to-be dangling
|
|
|
|
drop(b);
|
|
|
|
let b = Box::new(0);
|
|
|
|
let y = &*b as *const i32; // different allocation
|
|
|
|
// We cannot compare these even though both are inbounds -- they *could* be
|
|
|
|
// equal if memory was reused.
|
2019-06-23 10:26:12 -05:00
|
|
|
assert!(x != y); //~ ERROR invalid arithmetic on pointers
|
2018-09-15 10:12:48 -05:00
|
|
|
}
|