-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] convert withUnsafeBytes()
to typed throws
#72074
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
[stdlib] convert withUnsafeBytes()
to typed throws
#72074
Conversation
@swift-ci please test |
withUnsafeBytes()
to typed throws
f6c0f4f
to
b2f28d0
Compare
@swift-ci please test |
b2f28d0
to
b99900f
Compare
b99900f
to
e02d8ab
Compare
@swift-ci please test |
Update test/api-digester/stability-stdlib-abi-without-asserts.test
@swift-ci please test |
@swift-ci please test linux platform |
@swift-ci please test windows platform |
_ body: (UnsafeMutableRawBufferPointer) throws(E) -> Result | ||
) throws(E) -> Result { | ||
let pointer = UnsafeMutableRawPointer(Builtin.addressof(&value)) | ||
return try body(.init(start: pointer, count: MemoryLayout<T>.size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for writing this way instead of how the old thing was doing it? Not opposed, just curious 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old way crashed the compiler; going straight to the builtin is a workaround. (Not entirely successful, it seems.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The previous failure is likely fixed by #72152 |
@swift-ci please test |
Part of the ongoing conversion of standard library rethrows functions, after SE-0413.
This converts the top-level
withUnsafe[Mutable]Bytes(of:_:)
functions, and their corresponding no-stack-protection equivalents. There was no_withUnprotectedUnsafeMutableBytes()
previously — added here.