Skip to content

Faulty exclusivity check in Data.mutableSpan implementation #81218

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

Open
glessard opened this issue Apr 30, 2025 · 0 comments
Open

Faulty exclusivity check in Data.mutableSpan implementation #81218

glessard opened this issue Apr 30, 2025 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. exclusivity

Comments

@glessard
Copy link
Contributor

glessard commented Apr 30, 2025

Description

While implementing the Data.mutableSpan property (swiftlang/swift-foundation#1276), I tried to compose mutableSpan around the existing implementation of mutableBytes, and return a typed view. However, using the mutableBytes accessor within the mutableSpan accessor causes an exclusivity check to fail.

Reproduction

In swiftlang/swift-foundation#1276 , when changing the conditional compilation condition of the mutableSpan accessor (data.swift, line 2272) to true, an exclusivity check fails with the message:
"Overlapping accesses to 'self', but modification requires exclusive access; consider copying to a local variable."

The alternative implementation manually inlines the mutableBytes implementation, and that compiles successfully.

Expected behavior

Composing one accessor in terms of the other should work.

Environment

Toolchain built from top-of-tree, April 29th 2025.

Additional information

This issue was cloned by rdar://150396586

@glessard glessard added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. exclusivity labels Apr 30, 2025
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. exclusivity
Projects
None yet
Development

No branches or pull requests

2 participants