]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: casts from slices to array pointers are known to be non-nil
authorKeith Randall <khr@golang.org>
Fri, 24 Mar 2023 21:31:29 +0000 (14:31 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 29 Mar 2023 21:55:11 +0000 (21:55 +0000)
commit0d9eb8bea26a1fbebc149aa1811e5c0d9201dc40
tree30d5ad40b1fd4aab4187db9bd0c556b9402d55ce
parent9c75c4b6d75a1ee76f261f4fa7f3790efdbd51e4
cmd/compile: casts from slices to array pointers are known to be non-nil

The cast is proceeded by a bounds check. If the bounds check passes
then we know the pointer in the slice is non-nil.

... except casts to pointers of 0-sized arrays. They are strange, as
the bounds check can pass for a nil input.

Change-Id: Ic01cf4a82d59fbe3071d4b271c94efca9cafaec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/479335
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/ssagen/ssa.go
test/nilptr3.go