diff options
| author | Keith Randall <khr@google.com> | 2018-10-29 17:02:42 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2018-10-30 17:45:19 +0000 |
| commit | f14067f3c10e15343f29aed439ff60af856eb323 (patch) | |
| tree | ca12557f2c38befde553eeebdbe9ae7b0a38bedc /src | |
| parent | 5168fcf63f5001b38f9ac64ce5c5e3c2d397363d (diff) | |
| download | go-f14067f3c10e15343f29aed439ff60af856eb323.tar.xz | |
cmd/compile: when comparing 0-size types, make sure expr side-effects survive
Fixes #23837
Change-Id: I53f524d87946a0065f28a4ddbe47b40f2b43c459
Reviewed-on: https://go-review.googlesource.com/c/145757
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/gc/walk.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index c0fb5bfd28..0e07efa0d9 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -3297,6 +3297,14 @@ func walkcompare(n *Node, init *Nodes) *Node { } if expr == nil { expr = nodbool(n.Op == OEQ) + // We still need to use cmpl and cmpr, in case they contain + // an expression which might panic. See issue 23837. + t := temp(cmpl.Type) + a1 := nod(OAS, t, cmpl) + a1 = typecheck(a1, Etop) + a2 := nod(OAS, t, cmpr) + a2 = typecheck(a2, Etop) + init.Append(a1, a2) } n = finishcompare(n, expr, init) return n |
