Skip to content

Commit 742a96d

Browse files
authored
Merge pull request #81593 from tshortli/strict-memory-safety-warnings
stdlib: Resolve `-strict-memory-safety` warnings
2 parents e79760b + 58af3ce commit 742a96d

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

stdlib/public/Concurrency/ContinuousClock.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ extension ContinuousClock: Clock {
144144
extension ContinuousClock {
145145
@available(SwiftStdlib 5.7, *)
146146
@_alwaysEmitIntoClient
147-
public var systemEpoch: Instant { unsafeBitCast(Duration.seconds(0), to: Instant.self) }
147+
public var systemEpoch: Instant {
148+
unsafe unsafeBitCast(Duration.seconds(0), to: Instant.self)
149+
}
148150
}
149151

150152
@available(SwiftStdlib 5.7, *)

stdlib/public/Concurrency/Executor.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ extension SerialExecutor {
385385
#if SWIFT_CONCURRENCY_USES_DISPATCH
386386
@available(SwiftStdlib 6.2, *)
387387
private var _dispatchQueue: OpaquePointer? {
388-
return _getDispatchQueueForExecutor(self.asUnownedSerialExecutor())
388+
return unsafe _getDispatchQueueForExecutor(self.asUnownedSerialExecutor())
389389
}
390390
#endif
391391

@@ -395,8 +395,8 @@ extension SerialExecutor {
395395
return true
396396
}
397397
#if SWIFT_CONCURRENCY_USES_DISPATCH
398-
if let rhsQueue = rhs._dispatchQueue {
399-
if let ourQueue = _dispatchQueue, ourQueue == rhsQueue {
398+
if let rhsQueue = unsafe rhs._dispatchQueue {
399+
if let ourQueue = unsafe _dispatchQueue, ourQueue == rhsQueue {
400400
return true
401401
}
402402
return false

stdlib/public/Concurrency/SuspendingClock.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ extension SuspendingClock: Clock {
132132
extension SuspendingClock {
133133
@available(SwiftStdlib 5.7, *)
134134
@_alwaysEmitIntoClient
135-
public var systemEpoch: Instant { unsafeBitCast(Duration.seconds(0), to: Instant.self) }
135+
public var systemEpoch: Instant {
136+
unsafe unsafeBitCast(Duration.seconds(0), to: Instant.self)
137+
}
136138
}
137139

138140
@available(SwiftStdlib 5.7, *)

stdlib/toolchain/CompatibilitySpan/FakeStdlib.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ internal func _overrideLifetime<
7474
}
7575

7676
extension Range {
77-
@_alwaysEmitIntoClient
78-
internal init(_uncheckedBounds bounds: (lower: Bound, upper: Bound)) {
79-
self.init(uncheckedBounds: bounds)
80-
}
77+
@unsafe
78+
@_alwaysEmitIntoClient
79+
internal init(_uncheckedBounds bounds: (lower: Bound, upper: Bound)) {
80+
self.init(uncheckedBounds: bounds)
81+
}
8182
}
8283

8384
extension Optional {
@@ -90,4 +91,4 @@ extension Optional {
9091
_internalInvariantFailure("_unsafelyUnwrappedUnchecked of nil optional")
9192
}
9293
}
93-
}
94+
}

0 commit comments

Comments
 (0)