Skip to content
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

Enabling the InferSendableFromCaptures upcoming feature flag can break code that involves C functions #73313

Open
groue opened this issue Apr 27, 2024 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features

Comments

@groue
Copy link

groue commented Apr 27, 2024

Description

When I enable the upcoming feature flag InferSendableFromCaptures (from SE-0418), the Swift 6 compiler emits errors:

A C function pointer can only be formed from a reference to a 'func' or a literal closure.

Those errors are not emitted when InferSendableFromCaptures is not enabled.

Reproduction

import SQLite3

func f(_ cFunction: @convention(c) (OpaquePointer?) -> UnsafeMutablePointer<CChar>?) { }

func g() {
  // A C function pointer can only be formed from a reference to a 'func' or a literal closure
  f(sqlite3_expanded_sql)
}

Expected behavior

No compiler error.

Environment

$ /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-22-a.xctoolchain/usr/bin/swift --version
Apple Swift version 6.0-dev (LLVM 94447cf359772fc, Swift f36098a14a0d48b)
Target: arm64-apple-macosx14.0

Additional information

I've been using this technique for many years, with great success, inspired by this post on the Swift forums.

@groue groue added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Apr 27, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Apr 27, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Apr 27, 2024
@hborla hborla added concurrency Feature: umbrella label for concurrency language features and removed triage needed This issue needs more specific labels labels Apr 27, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Apr 28, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Apr 28, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Apr 28, 2024
@jckarter
Copy link
Member

#73436 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

No branches or pull requests

3 participants