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(
134
134
) -> Bool {
135
135
// Note: this assumes that AnyObject? is layout-compatible with a RawPointer
136
136
// that simply points to the same memory.
137
- var expected : UnsafeRawPointer ?
137
+ var expected : UnsafeRawPointer ? = nil
138
138
let unmanaged = Unmanaged . passRetained ( desired)
139
139
let desiredPtr = unmanaged. toOpaque ( )
140
140
let rawTarget = UnsafeMutableRawPointer ( target) . assumingMemoryBound (
141
141
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
+ }
144
147
if !wonRace {
145
148
// Some other thread initialized the value. Balance the retain that we
146
149
// performed on 'desired'.
You can’t perform that action at this time.
0 commit comments