Skip to content

Update the CHANGELOG for SE-0324: pointer arguments to C functions #39641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
Swift 5.6
---------

* [SE-0324][]:

Relax diagnostics for pointer arguments to C functions. The Swift
compiler now accepts limited pointer type mismatches when directly
calling functions imported from C as long as the C language allows
those pointer types to alias. Consequently, any Swift
`Unsafe[Mutable]Pointer<T>` or `Unsafe[Mutable]RawPointer` may be
passed to C function arguments declared as `[signed|unsigned] char
*`. Swift `Unsafe[Mutable]Pointer<T>` can also be passed to C
function arguments with an integer type that differs from `T` only
in its signedness.

For example, after importing a C function declaration:
```c
long long decode_int64(const char *ptr_to_int64);
```
Swift can now directly pass a raw pointer as the function argument:
```swift
func decodeAsInt64(data: Data) -> Int64 {
data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
decode_int64(bytes.baseAddress!)
}
}
```

* [SE-0315][]:

Type expressions and annotations can now include "type placeholders" which
Expand Down Expand Up @@ -8697,6 +8722,7 @@ Swift 1.0
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>

[SR-75]: <https://bugs.swift.org/browse/SR-75>
[SR-106]: <https://bugs.swift.org/browse/SR-106>
Expand Down