Commit 3bf005ce authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

cmd/gc: always treat the output parameters as having been assigned in capturevars.

Fixes #9738.

Change-Id: Iab75de2d78335d4e31c3dce6a0e1826d8cddf5f3
Reviewed-on: https://go-review.googlesource.com/3690Reviewed-by: 's avatarDmitry Vyukov <dvyukov@google.com>
parent 09114fb3
......@@ -209,7 +209,8 @@ capturevars(Node *xfunc)
dowidth(v->type);
outer = v->outerexpr;
v->outerexpr = N;
if(!v->closure->addrtaken && !v->closure->assigned && v->type->width <= 128)
// out parameters will be assigned to implicitly upon return.
if(outer->class != PPARAMOUT && !v->closure->addrtaken && !v->closure->assigned && v->type->width <= 128)
v->byval = 1;
else {
outer = nod(OADDR, outer, N);
......
// run
// Copyright 2015 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.
package main
func F() (x int) {
defer func() {
if x != 42 {
println("BUG: x =", x)
}
}()
return 42
}
func main() {
F()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment