-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[cxx-interop] Lifetime dependence on a class is unsafe #82725
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
[cxx-interop] Lifetime dependence on a class is unsafe #82725
Conversation
I'm a bit confused about this statement. Could you please explain it a little more? |
f524b6d to
fe123c3
Compare
Swift guarantees exclusivity for value types like structs and enums. On the other hand, people are free to share class types. As a result, the compiler or the runtime has no idea how many aliases are there for a class. But some Swift types like MutableSpan has exclusivity guarantees. Imagine something like: where |
b009445 to
4ac0826
Compare
4ac0826 to
86ed399
Compare
Swift cannot guarantee exclusivity of a class. On the other hand, lifetimebound annotations on the C++ side do not guarantee exclusivity. To resolve this issue, we ignore lifetime dependency annotations that introduce exclusive dependence on classes and import functions with ignored annotations as unsafe. Currently, Swift has no language feature to support these scenarios but it might get new features in the future to help people work around this problem. rdar://153747746
86ed399 to
f08868f
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test macos |
Swift cannot guarantee exclusivity of a class. On the other hand, lifetimebound annotations on the C++ side do not guarantee exclusivity. To resolve this issue, we ignore lifetime dependency annotations that introduce exclusive dependence on classes and import functions with ignored annotations as unsafe. Currently, Swift has no language feature to support these scenarios but it might get new features in the future to help people work around this problem.
rdar://153747746