Home | History | Annotate | Download | only in fixedbugs
      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 
      7 package main
      8 
      9 type A []int
     10 
     11 func 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 /*
     28 uetli:~/Source/go1/test/bugs gri$ 6g bug097.go && 6l bug097.6 && 6.out
     29 
     30 panic on line 342 PC=0x13c2
     31 0x13c2?zi
     32 	mainmain(1, 0, 1606416416, ...)
     33 	mainmain(0x1, 0x7fff5fbff820, 0x0, ...)
     34 SIGTRAP: trace trap
     35 Faulting address: 0x4558
     36 pc: 0x4558
     37 
     38 0x4558?zi
     39 	sysBreakpoint(40960, 0, 45128, ...)
     40 	sysBreakpoint(0xa000, 0xb048, 0xa000, ...)
     41 0x156a?zi
     42 	syspanicl(342, 0, 0, ...)
     43 	syspanicl(0x156, 0x300000000, 0xb024, ...)
     44 0x13c2?zi
     45 	mainmain(1, 0, 1606416416, ...)
     46 	mainmain(0x1, 0x7fff5fbff820, 0x0, ...)
     47 */
     48 
     49 /* An array composite literal needs to be created freshly every time.
     50 It is a "construction" of an array after all. If I pass the address
     51 of the array to some function, it may store it globally. Same applies
     52 to struct literals.
     53 */
     54