]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: prevent double-walk of switch for OPRINT/OPRINTN
authorDavid Chase <drchase@google.com>
Mon, 17 Dec 2018 17:01:56 +0000 (12:01 -0500)
committerDavid Chase <drchase@google.com>
Mon, 17 Dec 2018 22:49:21 +0000 (22:49 +0000)
commitd924c3336c39a256c832512ecd24fcdeed0ca266
tree432d7f926fbba49b577a881e3b8b03e52f526038
parent213845f7b932c72c5e49445224166d0ae14dfac9
cmd/compile: prevent double-walk of switch for OPRINT/OPRINTN

When a println arg contains a call to an inlineable function
that itself contains a switch, that switch statement will be
walked twice, once by the walkexprlist formerly in the
OPRINT/OPRINTN case, then by walkexprlistcheap in walkprint.

Remove the first walkexprlist, it is not necessary.
walkexprlist =
s[i] = walkexpr(s[i], init)
walkexprlistcheap = {
s[i] = cheapexpr(n, init)
s[i] = walkexpr(s[i], init)
}

Seems like this might be possible in other places, i.e.,
calls to inlineable switch-containing functions.

See also #25776.
Fixes #29220.

Change-Id: I3781e86aad6688711597b8bee9bc7ebd3af93601
Reviewed-on: https://go-review.googlesource.com/c/154497
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue29220.go [new file with mode: 0644]