]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/reallocate-change-alloc.rs
Merge pull request #376 from bjorn3/fix_some_tests
[rust.git] / tests / compile-fail / reallocate-change-alloc.rs
1 #![feature(alloc, allocator_api)]
2
3 extern crate alloc;
4
5 use alloc::alloc::Global;
6 use std::alloc::*;
7
8 fn main() {
9     unsafe {
10         let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
11         let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
12         let _z = *(x as *mut u8); //~ ERROR constant evaluation error [E0080]
13         //~^ NOTE dangling pointer was dereferenced
14     }
15 }