blob: 626fbbcac48374e53e26014d52f85a87377eba76 [file] [log] [blame]
Keith Randall31d13f42016-03-08 20:09:48 -08001// run
2
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07003// Copyright 2016 The Go Authors. All rights reserved.
Keith Randall31d13f42016-03-08 20:09:48 -08004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Test to make sure we don't think values are dead
8// when they are assigned to a PPARAMOUT slot before
9// the last GC safepoint.
10
11package main
12
13import (
14 "fmt"
15 "runtime"
16)
17
18// When a T is deallocated, T[1] is certain to
19// get clobbered (the runtime writes 0xdeaddeaddeaddead there).
20type T [4]int
21
22func f() (r, s *T) {
23 r = &T{0x30, 0x31, 0x32, 0x33}
24 runtime.GC()
25 s = &T{0x40, 0x41, 0x42, 0x43}
26 runtime.GC()
27 return
28}
29
30func main() {
31 r, s := f()
32 if r[1] != 0x31 {
33 fmt.Printf("bad r[1], want 0x31 got %x\n", r[1])
34 }
35 if s[1] != 0x41 {
36 fmt.Printf("bad s[1], want 0x41 got %x\n", s[1])
37 }
38}