forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#95328 - DrMeepster:box_gep_err, r=oli-obk
Fix yet another Box<T, A> ICE Fixes rust-lang#95036. This widens the special case from rust-lang#94414 to make sure that boxes with a custom allocator are never directly dereferenced.
- Loading branch information
Showing
2 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// compile-flags: -O | ||
// build-pass | ||
|
||
#![feature(allocator_api, bench_black_box)] | ||
|
||
#[inline(never)] | ||
pub fn by_ref(node: &mut Box<[u8; 1], &std::alloc::Global>) { | ||
node[0] = 9u8; | ||
} | ||
|
||
pub fn main() { | ||
let mut node = Box::new_in([5u8], &std::alloc::Global); | ||
node[0] = 7u8; | ||
|
||
std::hint::black_box(node); | ||
|
||
let mut node = Box::new_in([5u8], &std::alloc::Global); | ||
|
||
by_ref(&mut node); | ||
|
||
std::hint::black_box(node); | ||
} |