-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/go/ssa: tracking issue for ssa support of slice to array casts #47326
Comments
golang.org/x/tools/go/analysis/passes/nilness - The precision can be improved by propagating that the post condition of [reaching the next instruction after] a SliceToArrayPointer is non-nil if the array type has length >= 1 and if it is 0, the nilness of the instruction follows the nilness of the operand. Caveat: The bit in [] is that otherwise the SliceToArrayPointer instruction panic'd. I don't think this instruction can be referred to if a panic happened so I think this is an always okay interpretation. (Needs some thought. I doubt this is a serious concern for the checker though.) |
For the (indirect through x/tools/go/pointer) packages, no direct modifications are expected to be needed. x/tools/go/pointer just needs to be addressed before these packages are compatible with Go code containing slice to pointer-to-array casts. |
@timothy-king For example:
What should we do with the third conversion which can panic? |
If we know that the input to the cast is nil and the type has length >= 1, we can warn that the cast will always panic due to the nil. If it is not too much work a clearer message than "nil dereference in load" might be nice. Maybe "nil slice being cast to an array of len > 0 will always panic"? |
Change https://golang.org/cl/337709 mentions this issue: |
Change https://golang.org/cl/338849 mentions this issue: |
No interesting type flows so the change to vta itself is to not reject the instruction. Updates golang/go#47326 Change-Id: Ifd11a7ef854afaee3978796f3113ca3254301d19 Reviewed-on: https://go-review.googlesource.com/c/tools/+/338849 Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Zvonimir Pavlinovic <zpavlinovic@google.com> Trust: Roland Shoemaker <roland@golang.org>
Change https://golang.org/cl/339890 mentions this issue: |
Updates golang/go#47326 Change-Id: I6b9b59e82b1b93f7a328ba802ad473d4104d7577 Reviewed-on: https://go-review.googlesource.com/c/tools/+/339890 Run-TryBot: Tim King <taking@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Guodong Li <guodongli@google.com> Trust: Robert Findley <rfindley@google.com>
If we know that a nil slice is converted to a non-zero length array pointer, warn user that this operation will always panic. Updates golang/go#47326 Change-Id: Ic8adcc0255ddc621c5626dc5c525899b13e1c6b3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/337709 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tim King <taking@google.com>
Here are some data points on guru given
inside of a directory named "guru" while running guru from x/tools @6e9046bfcd341 with go version devel go1.18-a6ff433d6a Thu Aug 26 02:06:43 2021 +0000 darwin/amd64 I get
So it does not quite work right (#119,#123 refers to 'a[2]', #78,#83 refers to 'sl[2]') Looking at the guru code, it does not seem to need to treat *ssa.SliceToArrayPointer explicitly, it seems the problem is elsewhere. |
Change https://go.dev/cl/403354 mentions this issue: |
Adds a TODO list for the guru cmd. The main goal is document know issues that we have not addressed. Updates golang/go#47326 Updates golang/go#52503 Change-Id: I126b0f06081b606124d89a13f8805fa1ac6e56e3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/403354 TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com>
A new SliceToArrayPointer instruction is being added to x/tools/go/ssa to support the new Go 1.17 slice to pointer-to-an-array cast. Support for this new instruction should be propagated to the golang.org packages that could be impacted by this change. Most are in golang.org/x/tools.
This issue tracks the status of golang.org packages that use ssa that may be impacted by this change.
Other direct users of ssa that are not expected to be directly impacted:
The text was updated successfully, but these errors were encountered: