-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Description
This benchmark function has UB:
rust/library/alloc/src/collections/vec_deque/tests.rs
Lines 29 to 40 in bc3fae4
} | |
#[bench] | |
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks | |
fn bench_pop_back_100(b: &mut test::Bencher) { | |
let mut deq = VecDeque::<i32>::with_capacity(101); | |
b.iter(|| { | |
deq.head = 100; | |
deq.tail = 0; | |
while !deq.is_empty() { | |
test::black_box(deq.pop_back()); |
It directly accesses private fields of VecDeque
to set the head and tail pointers, but doesn't initialize the element in the middle so pop_back
reads uninitialized memory.
Metadata
Metadata
Assignees
Labels
No labels