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 @@ -134,13 +134,16 @@ func _stdlib_atomicInitializeARCRef(
134134) -> Bool {
135135 // Note: this assumes that AnyObject? is layout-compatible with a RawPointer
136136 // that simply points to the same memory.
137- var expected : UnsafeRawPointer ?
137+ var expected : UnsafeRawPointer ? = nil
138138 let unmanaged = Unmanaged . passRetained ( desired)
139139 let desiredPtr = unmanaged. toOpaque ( )
140140 let rawTarget = UnsafeMutableRawPointer ( target) . assumingMemoryBound (
141141 to: Optional< UnsafeRawPointer> . self )
142- let wonRace = _stdlib_atomicCompareExchangeStrongPtr (
143- object: rawTarget, expected: & expected, desired: desiredPtr)
142+ let wonRace = withUnsafeMutablePointer ( to: & expected) {
143+ _stdlib_atomicCompareExchangeStrongPtr (
144+ object: rawTarget, expected: $0, desired: desiredPtr
145+ )
146+ }
144147 if !wonRace {
145148 // Some other thread initialized the value. Balance the retain that we
146149 // performed on 'desired'.
You can’t perform that action at this time.
0 commit comments