Faulty exclusivity check in Data.mutableSpan
implementation
#81218
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
exclusivity
Description
While implementing the
Data.mutableSpan
property (swiftlang/swift-foundation#1276), I tried to composemutableSpan
around the existing implementation ofmutableBytes
, and return a typed view. However, using themutableBytes
accessor within themutableSpan
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
The text was updated successfully, but these errors were encountered: