1// run
2
3// Copyright 2016 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// Gccgo generated incorrect GC info when a global variable was
8// initialized to a slice of a value containing pointers.  The initial
9// backing array for the slice was allocated in the .data section,
10// which is fine, but the backing array was not registered as a GC
11// root.
12
13package main
14
15import (
16	"runtime"
17)
18
19type s struct {
20	str string
21}
22
23var a = []struct {
24	str string
25}{
26	{""},
27}
28
29var b = "b"
30var c = "c"
31
32func init() {
33	a[0].str = b + c
34}
35
36func main() {
37	runtime.GC()
38	if a[0].str != b + c {
39		panic(a[0].str)
40	}
41}
42