Skip to content

[stdlib, 6.2] Handle String's 32-bit inline representation for Span #82587

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

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Jun 27, 2025

String's inline representation is currently non-contiguous on 32-bit platforms. Furthermore, that representation is baked in ABI for watchOS's 32-bit variant. This PR implements mitigations.

A. For 32-bit platforms without ABI stability, we reduce the size of the inline representation to 8 UTF-8 code units (from 10).

B. For 32-bit watchOS, we add an optional property var _span: Span<UTF8.CodeUnit>? that returns nil when the representation of the String is non-contiguous, that is when it is 9 or 10 UTF-8 code units.

All platforms will get this underscored property, so that code that supports 32-bit watchOS doesn't have to be specific to it.

Scope: Bug fix for 32-bit platforms

Radar/SR Issue: rdar://147500261

Main PR: #82442

Risk: Low

Testing: Covered by unit tests

Reviewer: @lorentey

@glessard glessard requested a review from a team as a code owner June 27, 2025 22:20
@glessard
Copy link
Contributor Author

@swift-ci please test

@glessard glessard enabled auto-merge June 27, 2025 23:48
@glessard glessard merged commit 22fdbf3 into swiftlang:release/6.2 Jun 28, 2025
5 checks passed
@glessard glessard deleted the rdar147500261-utf8span-32bit-62 branch June 28, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants