We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c9a6b23 + 2f0d7d3 commit 75ea76dCopy full SHA for 75ea76d
rust-version
@@ -1 +1 @@
1
-3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a
+f0f68778f798d6d34649745b41770829b17ba5b8
tests/run-pass/leak-in-static.rs
@@ -1,8 +1,16 @@
+use std::{ptr, sync::atomic::{AtomicPtr, Ordering}};
2
+
3
static mut LEAKER: Option<Box<Vec<i32>>> = None;
4
5
fn main() {
6
// Having memory "leaked" in globals is allowed.
7
unsafe {
8
LEAKER = Some(Box::new(vec![0; 42]));
9
}
10
11
+ // Make sure this is allowed even when `AtomicPtr` is used.
12
+ {
13
+ static LEAK: AtomicPtr<usize> = AtomicPtr::new(ptr::null_mut());
14
+ LEAK.store(Box::into_raw(Box::new(0usize)), Ordering::SeqCst);
15
+ }
16
0 commit comments