8000 🍒[cxx-interop] Do not crash when emitting layout of `std::string` by egorzhdan · Pull Request #81872 · swiftlang/swift · GitHub
[go: up one dir, main page]

Skip to content

🍒[cxx-interop] Do not crash when emitting layout of std::string #81872

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
May 31, 2025

Conversation

egorzhdan
Copy link
Contributor
@egorzhdan egorzhdan commented May 30, 2025
  • Explanation: If a [[no_unique_address]] field has zero size according to Clang, and field has a type that isn't representable in Swift, Swift would previously try to add an opaque field of size 1 for it.
    This is wrong and was causing crashes for std::string while emitting a padding field:
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _);

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

If a `[[no_unique_address]]` field has zero size according to Clang, and field has a type that isn't representable in Swift, Swift would previously try to add an opaque field of size 1 for it.

This is wrong and was causing crashes for `std::string` while emitting a padding field:
```
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _);
```

rdar://151941799
(cherry picked from commit a7c1744)
@egorzhdan egorzhdan force-pushed the egorzhdan/6.2-zero-sized-no-unique-address branch from 1b7d221 to ee5f7ad Compare May 30, 2025 16:33
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review May 30, 2025 16:53
@egorzhdan egorzhdan requested a review from a team as a code owner May 30, 2025 16:53
@egorzhdan egorzhdan enabled auto-merge May 30, 2025 19:06
@egorzhdan egorzhdan merged commit 3688f6a into release/6.2 May 31, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.2-zero-sized-no-unique-address branch May 31, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0