]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/gc: reject invalid unsafe.Sizeof([0]byte{}[0])
authorMatthew Dempsky <mdempsky@google.com>
Thu, 15 Oct 2015 18:29:06 +0000 (11:29 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 15 Oct 2015 20:56:58 +0000 (20:56 +0000)
commit67722fea5015d43d8fc9a533533c9b580fa99fc8
tree627200acb89f0f9e9e0f6ef3d46c763a11002a54
parent7eb94db44c6ebaaf5f94629f66fddb4a78ebd34a
cmd/compile/internal/gc: reject invalid unsafe.Sizeof([0]byte{}[0])

Apply static bounds checking logic during type checking even to
zero-element arrays, but skip synthesized OINDEX nodes that the
compiler has asserted are within bounds (such as the ones generated
while desugaring ORANGE nodes).  This matches the logic in walkexpr
that also skips static bounds checking when Bounded is true.

Passes toolstash/buildall.

Fixes #12944.

Change-Id: I14ba03d71c002bf969d69783bec8d1a8e10e7d75
Reviewed-on: https://go-review.googlesource.com/15902
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue12944.go [new file with mode: 0644]