diff options
author | Russ Cox <rsc@golang.org> | 2014-05-27 23:59:06 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-05-27 23:59:06 -0400 |
commit | 356480413cb73a7d68ced56a358284ff0803aa24 (patch) | |
tree | 5e7d71b838575276dfcb2b7e48573b3a13577563 /test/fixedbugs | |
parent | 7ace5f6bd3919cb0678e17e7a634d2197a5dc539 (diff) | |
download | go-356480413cb73a7d68ced56a358284ff0803aa24.tar.gz |
cmd/gc: fix defer copy(x, <-c)
In the first very rough draft of the reordering code
that was introduced in the Go 1.3 cycle, the pre-allocated
temporary for a ... argument was held in n->right.
It moved to n->alloc but the code avoiding n->right
was left behind in order.c. In copy(x, <-c), the receive
is in n->right and must be processed. Delete the special
case code, removing the bug.
Fixes issue 8039.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/100820044
Diffstat (limited to 'test/fixedbugs')
-rw-r--r-- | test/fixedbugs/issue8039.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/fixedbugs/issue8039.go b/test/fixedbugs/issue8039.go new file mode 100644 index 000000000..b13e474d9 --- /dev/null +++ b/test/fixedbugs/issue8039.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 8039. defer copy(x, <-c) did not rewrite <-c properly. + +package main + +func f(s []int) { + c := make(chan []int, 1) + c <- []int{1} + defer copy(s, <-c) +} + +func main() { + x := make([]int, 1) + f(x) + if x[0] != 1 { + println("BUG", x[0]) + } +} |