Skip to content

Commit 9bf4c71

Browse files
authored
Change 'unsafeDowncast' to 'as!' (#52)
Motivation: The 'unsafeDowncast' can cause a miscompile leading to unexpected runtime behaviour. Modifications: - Use 'as!' instead Result: No miscompiles on 5.10
1 parent 50e1f4a commit 9bf4c71

File tree

1 file changed

+2
-1
lines changed
  • Sources/OpenAPIURLSession/BufferedStream

1 file changed

+2
-1
lines changed

Sources/OpenAPIURLSession/BufferedStream/Lock.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
111111
let buffer = Self.create(minimumCapacity: 1) { _ in
112112
return value
113113
}
114-
let storage = unsafeDowncast(buffer, to: Self.self)
114+
// Avoid 'unsafeDowncast' as there is a miscompilation on 5.10.
115+
let storage = buffer as! Self
115116

116117
storage.withUnsafeMutablePointers { _, lockPtr in
117118
LockOperations.create(lockPtr)

0 commit comments

Comments
 (0)