diff options
| author | bors <bors@rust-lang.org> | 2023-01-25 17:49:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-01-25 17:49:12 +0000 |
| commit | 3ed2c0aa3138c88e4de77d04ca1832848881b28f (patch) | |
| tree | 595d8424e48d81cc0fa085507a11cb43f6d7a99a | |
| parent | 9defdc7c13a03475dcdf2409f698355c87fd67f0 (diff) | |
| parent | ff5132e2fc2e2bc5a6669c67c9c2d2fa208fd5f0 (diff) | |
Auto merge of #2765 - RalfJung:scfix, r=RalfJung
add scfix test I'm not sure if we currently *guarantee* to pass this test, but at least I was unable to get it to fail. Cc `@cbeuw`
| -rw-r--r-- | src/tools/miri/tests/pass/0weak_memory_consistency.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/0weak_memory_consistency.rs b/src/tools/miri/tests/pass/0weak_memory_consistency.rs index f3820bd660d..7861acd4ef7 100644 --- a/src/tools/miri/tests/pass/0weak_memory_consistency.rs +++ b/src/tools/miri/tests/pass/0weak_memory_consistency.rs @@ -286,6 +286,40 @@ fn test_iriw_sc_rlx() { assert!(c || d); } +// Another test for C++20 SCfix. +fn scfix() { + let x = static_atomic_bool(false); + let y = static_atomic_bool(false); + + let thread1 = spawn(move || { + let a = x.load(Relaxed); + fence(SeqCst); + let b = y.load(Relaxed); + (a, b) + }); + + let thread2 = spawn(move || { + x.store(true, Relaxed); + }); + let thread3 = spawn(move || { + x.store(true, Relaxed); + }); + + let thread4 = spawn(move || { + let c = y.load(Relaxed); + fence(SeqCst); + let d = x.load(Relaxed); + (c, d) + }); + + let (a, b) = thread1.join().unwrap(); + thread2.join().unwrap(); + thread3.join().unwrap(); + let (c, d) = thread4.join().unwrap(); + let bad = a == true && b == false && c == true && d == false; + assert!(!bad); +} + pub fn main() { for _ in 0..50 { test_single_thread(); @@ -297,5 +331,6 @@ pub fn main() { test_sc_store_buffering(); test_sync_through_rmw_and_fences(); test_iriw_sc_rlx(); + scfix(); } } |
