File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -133,13 +133,16 @@ func _stdlib_atomicInitializeARCRef(
133
133
) -> Bool {
134
134
// Note: this assumes that AnyObject? is layout-compatible with a RawPointer
135
135
// that simply points to the same memory.
136
- var expected : UnsafeRawPointer ?
136
+ var expected : UnsafeRawPointer ? = nil
137
137
let unmanaged = Unmanaged . passRetained ( desired)
138
138
let desiredPtr = unmanaged. toOpaque ( )
139
139
let rawTarget = UnsafeMutableRawPointer ( target) . assumingMemoryBound (
140
140
to: Optional< UnsafeRawPointer> . self )
141
- let wonRace = _stdlib_atomicCompareExchangeStrongPtr (
142
- object: rawTarget, expected: & expected, desired: desiredPtr)
141
+ let wonRace = withUnsafeMutablePointer ( to: & expected) {
142
+ _stdlib_atomicCompareExchangeStrongPtr (
143
+ object: rawTarget, expected: $0, desired: desiredPtr
144
+ )
145
+ }
143
146
if !wonRace {
144
147
// Some other thread initialized the value. Balance the retain that we
145
148
// performed on 'desired'.
You can’t perform that action at this time.
0 commit comments