1// run
2
3// Copyright 2014 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Issue 8036. Stores necessary for stack scan being eliminated as redundant by optimizer.
8
9package main
10
11import "runtime"
12
13type T struct {
14	X *int
15	Y *int
16	Z *int
17}
18
19type TI [3]uintptr
20
21//go:noinline
22func G() (t TI) {
23	t[0] = 1
24	t[1] = 2
25	t[2] = 3
26	return
27}
28
29//go:noinline
30func F() (t T) {
31	t.X = newint()
32	t.Y = t.X
33	t.Z = t.Y
34	return
35}
36
37func newint() *int {
38	runtime.GC()
39	return nil
40}
41
42func main() {
43	G() // leave non-pointers where F's return values go
44	F()
45}
46