Skip to content

Commit 2d2a181

Browse files
committed
[stdlib] UnsafeMutableRawPointer: storeBytes of ~Escapable
Only supports non-BitwiseCopyable values. The generic storeBytes should also be supported but it depends on UnsafePointer<T: ~Escapable>.
1 parent 227c1c5 commit 2d2a181

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

stdlib/public/core/UnsafeRawPointer.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,11 @@ extension UnsafeMutableRawPointer {
14181418
/// - type: The type of `value`.
14191419
@inlinable
14201420
@_alwaysEmitIntoClient
1421-
public func storeBytes<T: BitwiseCopyable>(
1421+
public func storeBytes<T: BitwiseCopyable & ~Escapable>(
14221422
of value: T, toByteOffset offset: Int = 0, as type: T.Type
14231423
) {
1424-
unsafe Builtin.storeRaw(value, (self + offset)._rawValue)
1424+
let immortalValue = unsafe _overrideLifetime(value, borrowing: ())
1425+
unsafe Builtin.storeRaw(immortalValue, (self + offset)._rawValue)
14251426
}
14261427

14271428
/// Stores the given value's bytes into raw memory at the specified offset.

0 commit comments

Comments
 (0)