Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/pass/0weak_memory/weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ fn old_release_store() {
});
}

/// 2+2W variant https://johnwickerson.github.io/papers/memalloy.pdf §4.1
/// 3 SC + 1 Rel is the strongest ordering to still observe x==y==1
fn two_w_two_w() {
check_all_outcomes([1, 1], || {
Copy link
Member

@RalfJung RalfJung Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks y, and it checks that that is always 1...?

The slice here is the set of all outcomes, so [1, 1] is equivalent to [1].

let x = static_atomic(0);
let y = static_atomic(0);

let t1 = spawn(move || {
x.store(1, SeqCst);
y.store(2, SeqCst);
x.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
y.load(Relaxed)
Comment on lines +239 to +244
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code doesn't match the cppmem code. It should be:

Suggested change
x.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
y.load(Relaxed)
y.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
x.load(Relaxed)

});

t1.join().unwrap();
t2.join().unwrap()
});
}

fn main() {
relaxed();
seq_cst();
Expand All @@ -235,4 +258,5 @@ fn main() {
release_sequence();
weaker_release_sequences();
old_release_store();
two_w_two_w();
}