aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-02 14:47:26 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-02 14:47:26 -0400
commit90e64bc620edc3f3c3a2c16d01b7ca2eefc02429 (patch)
tree42280ec202a86a5fab37ed5b6e38f38792ab8042 /test
parenta5cb0f77d11bdcc504fe3e6afa928c88de821518 (diff)
downloadzig-90e64bc620edc3f3c3a2c16d01b7ca2eefc02429.tar.gz
zig-90e64bc620edc3f3c3a2c16d01b7ca2eefc02429.zip
fix cmpxchg with discarded result
Diffstat (limited to 'test')
-rw-r--r--test/stage1/behavior/atomics.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/stage1/behavior/atomics.zig b/test/stage1/behavior/atomics.zig
index a97467e416..1a941cf21c 100644
--- a/test/stage1/behavior/atomics.zig
+++ b/test/stage1/behavior/atomics.zig
@@ -1,5 +1,6 @@
const std = @import("std");
const expect = std.testing.expect;
+const expectEqual = std.testing.expectEqual;
const builtin = @import("builtin");
const AtomicRmwOp = builtin.AtomicRmwOp;
const AtomicOrder = builtin.AtomicOrder;
@@ -90,3 +91,12 @@ test "cmpxchg with ptr" {
// expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null);
// expect(x == 42);
//}
+
+test "cmpxchg with ignored result" {
+ var x: i32 = 1234;
+ var ptr = &x;
+
+ _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic);
+
+ expectEqual(i32(5678), x);
+}