-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Util: add StringData, String, SliceData(go 1.20) #2472
Comments
monkey92t
changed the title
add StringData, String, SliceData(go 1.20)
Util: add StringData, String, SliceData(go 1.20)
Mar 3, 2023
Will this be done part by part or all at once? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See golang/go#53003
As stated in Proposal:
The first use case can also commonly be seen as *(*string)(unsafe.Pointer(&mySlice)), which is never actually officially documented anywhere as something that can be relied upon. Under the hood, the shape of a string is less than a slice, so this seems valid per unsafe rule (1), but this is all relying on undocumented behavior. The second use case is commonly seen as ([]byte)(unsafe.Pointer(&string)), which is by-default broken because the Cap field can be past the end of a page boundary (example here, in widely used code) -- this violates unsafe rule (1).
:)
The text was updated successfully, but these errors were encountered: