| author | |
| committer | |
| log | 2f740fa19ff88981d028289162b3eb469b7f5315 |
| tree | e8a4f78bbb908a887fc44f7a9a2c4808a0323274 |
| parent | 711520d935fd7f6367f1d3a0c2c01c140647b4d0 |
Fixes #35822 files changed, 9 insertions(+), 1 deletions(-)
src/ir.cpp+2-1| ... | ... | @@ -21798,7 +21798,8 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 21798 | 21798 | return ira->codegen->invalid_instruction; |
| 21799 | 21799 | } |
| 21800 | 21800 | |
| 21801 | if (instr_is_comptime(casted_ptr) && instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { | |
| 21801 | if (instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar && | |
| 21802 | instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { | |
| 21802 | 21803 | zig_panic("TODO compile-time execution of cmpxchg"); |
| 21803 | 21804 | } |
| 21804 | 21805 |
test/stage1/behavior/atomics.zig+7| ... | ... | @@ -100,3 +100,10 @@ test "cmpxchg with ignored result" { |
| 100 | 100 | |
| 101 | 101 | expectEqual(i32(5678), x); |
| 102 | 102 | } |
| 103 | ||
| 104 | var a_global_variable = u32(1234); | |
| 105 | ||
| 106 | test "cmpxchg on a global variable" { | |
| 107 | _ = @cmpxchgWeak(u32, &a_global_variable, 1234, 42, .Acquire, .Monotonic); | |
| 108 | expectEqual(u32(42), a_global_variable); | |
| 109 | } |