This benchmark function has UB:
|
} |
|
|
|
#[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.
This benchmark function has UB:
rust/library/alloc/src/collections/vec_deque/tests.rs
Lines 29 to 40 in bc3fae4
It directly accesses private fields of
VecDequeto set the head and tail pointers, but doesn't initialize the element in the middle sopop_backreads uninitialized memory.