rust/src/test/compile-fail/mutable-huh-ptr-assign.rs

17 lines
262 B
Rust
Raw Normal View History

2011-10-17 17:41:38 -05:00
// error-pattern: assigning to immutable box
use std;
fn main() {
unsafe fn f(&&v: *mutable? int) {
// This shouldn't be possible
*v = 1
}
unsafe {
let a = 0;
let v = std::ptr::mut_addr_of(a);
2011-10-17 17:41:38 -05:00
f(v);
}
}