Skip to content
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

[SR-13869] ManagedBufferPointer's header property should have nonmutating setter #56267

Open
lilyball mannequin opened this issue Nov 18, 2020 · 2 comments
Open

[SR-13869] ManagedBufferPointer's header property should have nonmutating setter #56267

lilyball mannequin opened this issue Nov 18, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Nov 18, 2020

Previous ID SR-13869
Radar rdar://problem/70458271
Original Reporter @lilyball
Type Bug
Environment

Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
Target: x86_64-apple-darwin19.6.0

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: b373a44203d77dd35d0394ac0765ce07

Issue Description:

ManagedBufferPointer has a header property that provides quick access to the header. Unfortunately its setter requires the pointer itself to be mutable, even though no other usage of this type (including withUnsafeMutablePointerToHeader(_:)) has this requirement, and the type itself is supposed to act as a pointer. This seems like an oversight.

class Buffer {}
let ptr = ManagedBufferPointer<Int,Int>(bufferClass: Buffer.self, minimumCapacity: 5, makingHeaderWith: { (_,_) in 0 })
// this works
ptr.withUnsafeMutablePointerToHeader { $0.pointee = 1 }
// this won't compile unless ptr is turned into var
ptr.header = 1
@typesanitizer
Copy link

@swift-ci create

@lorentey
Copy link
Member

Yep, this is yet another ManagedBufferPointer wrinkle we need to iron out somehow. `header` should have a nonmutating _modify accessor.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants