]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: fix two select temporary bugs
authorRuss Cox <rsc@golang.org>
Thu, 15 May 2014 23:16:18 +0000 (19:16 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 15 May 2014 23:16:18 +0000 (19:16 -0400)
commit1357f548b06c7e6b0934c565418ab7af3e6ea783
treef591e1c77d693850c43eb81846f51b830dec72ec
parent6d63d4f3be32bfd3dbc57fe6872d315369c59c6d
cmd/gc: fix two select temporary bugs

The introduction of temporaries in order.c was not
quite right for two corner cases:

1) The rewrite that pushed new variables on the lhs of
a receive into the body of the case was dropping the
declaration of the variables. If the variables escape,
the declaration is what allocates them.
Caught by escape analysis sanity check.
In fact the declarations should move into the body
always, so that we only allocate if the corresponding
case is selected. Do that. (This is an optimization that
was already present in Go 1.2. The new order code just
made it stop working.)

Fixes #7997.

2) The optimization to turn a single-recv select into
an ordinary receive assumed it could take the address
of the destination; not so if the destination is _.

Fixes #7998.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100480043
src/cmd/gc/order.c
src/cmd/gc/walk.c
test/fixedbugs/issue7997.go [new file with mode: 0644]
test/fixedbugs/issue7998.go [new file with mode: 0644]