Skip to content

Commit 7bd26e4

Browse files
committed
[ChangeLog] add SE-0349
1 parent f160e2b commit 7bd26e4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0349][]:
9+
10+
Loading data from raw memory represented by `UnsafeRawPointer`,
11+
`UnsafeRawBufferPointer` and their mutable counterparts now supports unaligned
12+
accesses. This previously required a workaround involving an intermediate
13+
copy:
14+
15+
```swift
16+
let result = unalignedData.withUnsafeBytes { buffer -> UInt32 in
17+
var storage = UInt32.zero
18+
withUnsafeMutableBytes(of: &storage) {
19+
$0.copyBytes(from: buffer.prefix(MemoryLayout<UInt32>.size))
20+
}
21+
return storage
22+
}
23+
```
24+
Now:
25+
```swift
26+
let result = unalignedData.withUnsafeBytes { $0.loadUnaligned(as: UInt32.self) }
27+
```
28+
Additionally, the counterpart `storeBytes(of:toByteOffset:as:)` had its
29+
alignment restriction lifted, so that storing to arbitrary offsets of raw
30+
memory can now succeed.
31+
832
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on the `AnyObject` metatype are now supported. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
933

1034
```swift
@@ -9203,6 +9227,7 @@ Swift 1.0
92039227
[SE-0345]: <https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md>
92049228
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
92059229
[SE-0347]: <https://github.com/apple/swift-evolution/blob/main/proposals/0347-type-inference-from-default-exprs.md>
9230+
[SE-0349]: <https://github.com/apple/swift-evolution/blob/main/proposals/0349-unaligned-loads-and-stores.md>
92069231
[SE-0352]: <https://github.com/apple/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md>
92079232

92089233
[SR-75]: <https://bugs.swift.org/browse/SR-75>

0 commit comments

Comments
 (0)