]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: ignore out-of-bounds reads from readonly constants
authorKeith Randall <keithr@alum.mit.edu>
Thu, 13 Dec 2018 17:31:21 +0000 (09:31 -0800)
committerKeith Randall <khr@golang.org>
Thu, 20 Dec 2018 17:34:32 +0000 (17:34 +0000)
commit443990742ec6dd128fab41d4afaa8668e665eadd
treeacf6f6274f6be89ebaac19bdc0285d1632cad905
parent4422319fbf8db7700752ae2a755244bbd24672de
cmd/compile: ignore out-of-bounds reads from readonly constants

Out-of-bounds reads of globals can happen in dead code. For code
like this:

s := "a"
if len(s) == 3 {
   load s[0], s[1], and s[2]
}

The out-of-bounds loads are dead code, but aren't removed yet
when lowering. We need to not panic when compile-time evaluating
those loads. This can only happen for dead code, so the result
doesn't matter.

Fixes #29215

Change-Id: I7fb765766328b9524c6f2a1e6ab8d8edd9875097
Reviewed-on: https://go-review.googlesource.com/c/154057
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
src/cmd/compile/internal/ssa/rewrite.go
test/fixedbugs/issue29215.go [new file with mode: 0644]