blob: bea2a5949c261eca67cbfb6a122e8e312493214a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// Ensure that once an allocation is "made global", we can no longer mutate it.
#![feature(core_intrinsics)]
#![feature(const_heap)]
use std::intrinsics;
const A: &u8 = unsafe {
let ptr = intrinsics::const_allocate(1, 1);
*ptr = 1;
let ptr: *const u8 = intrinsics::const_make_global(ptr);
*(ptr as *mut u8) = 2;
//~^ error: writing to ALLOC0 which is read-only
&*ptr
};
fn main() {}
|