1// run
2
3// Copyright 2009 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
7package main
8
9type A []int
10
11func main() {
12	var a [3]A
13	for i := 0; i < 3; i++ {
14		a[i] = A{i}
15	}
16	if a[0][0] != 0 {
17		panic("fail a[0][0]")
18	}
19	if a[1][0] != 1 {
20		panic("fail a[1][0]")
21	}
22	if a[2][0] != 2 {
23		panic("fail a[2][0]")
24	}
25}
26
27/*
28uetli:~/Source/go1/test/bugs gri$ 6g bug097.go && 6l bug097.6 && 6.out
29
30panic on line 342 PC=0x13c2
310x13c2?zi
32	main·main(1, 0, 1606416416, ...)
33	main·main(0x1, 0x7fff5fbff820, 0x0, ...)
34SIGTRAP: trace trap
35Faulting address: 0x4558
36pc: 0x4558
37
380x4558?zi
39	sys·Breakpoint(40960, 0, 45128, ...)
40	sys·Breakpoint(0xa000, 0xb048, 0xa000, ...)
410x156a?zi
42	sys·panicl(342, 0, 0, ...)
43	sys·panicl(0x156, 0x300000000, 0xb024, ...)
440x13c2?zi
45	main·main(1, 0, 1606416416, ...)
46	main·main(0x1, 0x7fff5fbff820, 0x0, ...)
47*/
48
49/* An array composite literal needs to be created freshly every time.
50It is a "construction" of an array after all. If I pass the address
51of the array to some function, it may store it globally. Same applies
52to struct literals.
53*/
54