-
Notifications
You must be signed in to change notification settings - Fork 18k
unsafe: Slice does not panic on nil pointer when element size is 0 #54092
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
Comments
Isn't it #46742? |
That issue is about |
Ah right, it does panic with go.17, though https://go.dev/play/p/bpbEmh22qZA?v=goprev |
Nice find. It looks like the issue is we rely on We can add an extra explicit Maybe we can add it to the 64-bit entry point, and just force use of that function for zero-size types? |
We could generate entirely different code for the elemsize==0 case. |
Change https://go.dev/cl/419755 mentions this issue: |
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes: golang#54092
…elem) == 0 and > 0 Fixes golang#54092
…elem) == 0 and > 0 Fixes golang#54092
Fixes golang#54092 Change-Id: Ib917922ed36ee5410e5515f812737203c44f46ae GitHub-Last-Rev: dfd0c38 GitHub-Pull-Request: golang#54107 Reviewed-on: https://go-review.googlesource.com/c/go/+/419755 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This program should panic:
From the
unsafe.Slice
docs:A zero-sized element is a very special case here, so just a doc fix would be fine also.
@cuonglm @mdempsky
The text was updated successfully, but these errors were encountered: