This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,35 @@ fn test_sync_through_rmw_and_fences() {
257
257
assert_ne ! ( ( a, b) , ( 0 , 0 ) ) ;
258
258
}
259
259
260
+ // Test case by @SabrinaJewson
261
+ // https://github.com/rust-lang/miri/issues/2301#issuecomment-1221502757
262
+ // Demonstrating C++20 SC access changes
263
+ fn test_iriw_sc_rlx ( ) {
264
+ let x = static_atomic_bool ( false ) ;
265
+ let y = static_atomic_bool ( false ) ;
266
+
267
+ x. store ( false , Relaxed ) ;
268
+ y. store ( false , Relaxed ) ;
269
+
270
+ let a = spawn ( move || x. store ( true , Relaxed ) ) ;
271
+ let b = spawn ( move || y. store ( true , Relaxed ) ) ;
272
+ let c = spawn ( move || {
273
+ while !x. load ( SeqCst ) { }
274
+ y. load ( SeqCst )
275
+ } ) ;
276
+ let d = spawn ( move || {
277
+ while !y. load ( SeqCst ) { }
278
+ x. load ( SeqCst )
279
+ } ) ;
280
+
281
+ a. join ( ) . unwrap ( ) ;
282
+ b. join ( ) . unwrap ( ) ;
283
+ let c = c. join ( ) . unwrap ( ) ;
284
+ let d = d. join ( ) . unwrap ( ) ;
285
+
286
+ assert ! ( c || d) ;
287
+ }
288
+
260
289
pub fn main ( ) {
261
290
for _ in 0 ..50 {
262
291
test_single_thread ( ) ;
@@ -267,5 +296,6 @@ pub fn main() {
267
296
test_corr ( ) ;
268
297
test_sc_store_buffering ( ) ;
269
298
test_sync_through_rmw_and_fences ( ) ;
299
+ test_iriw_sc_rlx ( ) ;
270
300
}
271
301
}
You can’t perform that action at this time.
0 commit comments