File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/tools/miri/tests/pass Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,40 @@ fn test_iriw_sc_rlx() {
286
286
assert ! ( c || d) ;
287
287
}
288
288
289
+ // Another test for C++20 SCfix.
290
+ fn scfix ( ) {
291
+ let x = static_atomic_bool ( false ) ;
292
+ let y = static_atomic_bool ( false ) ;
293
+
294
+ let thread1 = spawn ( move || {
295
+ let a = x. load ( Relaxed ) ;
296
+ fence ( SeqCst ) ;
297
+ let b = y. load ( Relaxed ) ;
298
+ ( a, b)
299
+ } ) ;
300
+
301
+ let thread2 = spawn ( move || {
302
+ x. store ( true , Relaxed ) ;
303
+ } ) ;
304
+ let thread3 = spawn ( move || {
305
+ x. store ( true , Relaxed ) ;
306
+ } ) ;
307
+
308
+ let thread4 = spawn ( move || {
309
+ let c = y. load ( Relaxed ) ;
310
+ fence ( SeqCst ) ;
311
+ let d = x. load ( Relaxed ) ;
312
+ ( c, d)
313
+ } ) ;
314
+
315
+ let ( a, b) = thread1. join ( ) . unwrap ( ) ;
316
+ thread2. join ( ) . unwrap ( ) ;
317
+ thread3. join ( ) . unwrap ( ) ;
318
+ let ( c, d) = thread4. join ( ) . unwrap ( ) ;
319
+ let bad = a == true && b == false && c == true && d == false ;
320
+ assert ! ( !bad) ;
321
+ }
322
+
289
323
pub fn main ( ) {
290
324
for _ in 0 ..50 {
291
325
test_single_thread ( ) ;
@@ -297,5 +331,6 @@ pub fn main() {
297
331
test_sc_store_buffering ( ) ;
298
332
test_sync_through_rmw_and_fences ( ) ;
299
333
test_iriw_sc_rlx ( ) ;
334
+ scfix ( ) ;
300
335
}
301
336
}
You can’t perform that action at this time.
0 commit comments