]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use the zero value for results of impossible indexing
authorKeith Randall <khr@golang.org>
Tue, 31 Aug 2021 21:09:41 +0000 (14:09 -0700)
committerKeith Randall <khr@golang.org>
Tue, 31 Aug 2021 21:49:48 +0000 (21:49 +0000)
commit1f83a8c16cf1e9141e081759fb0f6c6f2acb5fdc
tree0f0108706b66480e254e8d169836a3890f695f15
parentbb0b511738713c7a8cc4c194e037a7ea852751ca
cmd/compile: use the zero value for results of impossible indexing

type A [0]int
var a A
x := a[i]

Use the zero value for x instead of the "impossible" value. That lets
us at least compile code like this with -B, even though it can't
possibly run correctly.

Fixes #48092

Change-Id: Idad5cfab49e05f375c069b05addceed68a15299f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346589
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/compile/internal/ssagen/ssa.go
test/fixedbugs/issue48092.go [new file with mode: 0644]