Skip to content

[cxx-interop] Fix spurious lifetime dependence errors #78807

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
Jan 29, 2025

Conversation

Xazax-hun
Copy link
Contributor

ClangImporter will generate value and default initializers for certain structs imported from C++. These generated initializers have no associated lifetime dependence information so they will trigger spurious errors for non-escapable types. This patch makes sure these are marked as unsafe so the type checker will not generate errors for them. Moreover, the generated default initializer would trigger a crash for non-escapable types as the builtin to zero initialize an object does not support non-escapable types yet.

rdar://143040862

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Jan 22, 2025
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

Comment on lines +2429 to +2432
// TODO: builtin "zeroInitializer" does not work with non-escapable
// types yet. Don't generate an initializer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if we're tracking this issue yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to find anything. Will ask around if people are aware of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened one just in case: rdar://143828851

ClangImporter will generate value and default initializers for certain
structs imported from C++. These generated initializers have no
associated lifetime dependence information so they will trigger spurious
errors for non-escapable types. This patch makes sure these are marked
as unsafe so the type checker will not generate errors for them.
Moreover, the generated default initializer would trigger a crash for
non-escapable types as the builtin to zero initialize an object does not
support non-escapable types yet.

rdar://143040862
@Xazax-hun Xazax-hun force-pushed the gaborh/generated-ctors branch from c9cd3c5 to b6fce85 Compare January 22, 2025 15:34
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun Xazax-hun merged commit 109e208 into main Jan 29, 2025
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/generated-ctors branch January 29, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants