| 
									
										
										
										
											2008-09-11 17:11:16 -07:00
										 |  |  | // $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Copyright 2009 The Go Authors. All rights reserved. | 
					
						
							|  |  |  | // Use of this source code is governed by a BSD-style | 
					
						
							|  |  |  | // license that can be found in the LICENSE file. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 14:40:40 -08:00
										 |  |  | type A []int; | 
					
						
							| 
									
										
										
										
											2008-09-11 17:11:16 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							| 
									
										
										
										
											2009-01-05 13:09:34 -08:00
										 |  |  | 	var a [3]A; | 
					
						
							| 
									
										
										
										
											2008-09-11 17:11:16 -07:00
										 |  |  | 	for i := 0; i < 3; i++ { | 
					
						
							| 
									
										
										
										
											2009-03-03 08:39:12 -08:00
										 |  |  | 		a[i] = A{i}; | 
					
						
							| 
									
										
										
										
											2008-09-11 17:11:16 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if a[0][0] != 0 { panic(); } | 
					
						
							|  |  |  | 	if a[1][0] != 1 { panic(); } | 
					
						
							|  |  |  | 	if a[2][0] != 2 { panic(); } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | uetli:~/Source/go1/test/bugs gri$ 6g bug097.go && 6l bug097.6 && 6.out | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | panic on line 342 PC=0x13c2 | 
					
						
							|  |  |  | 0x13c2?zi | 
					
						
							|  |  |  | 	main·main(1, 0, 1606416416, ...) | 
					
						
							|  |  |  | 	main·main(0x1, 0x7fff5fbff820, 0x0, ...) | 
					
						
							|  |  |  | SIGTRAP: trace trap | 
					
						
							|  |  |  | Faulting address: 0x4558 | 
					
						
							|  |  |  | pc: 0x4558 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 0x4558?zi | 
					
						
							| 
									
										
										
										
											2009-01-16 14:58:14 -08:00
										 |  |  | 	sys·Breakpoint(40960, 0, 45128, ...) | 
					
						
							|  |  |  | 	sys·Breakpoint(0xa000, 0xb048, 0xa000, ...) | 
					
						
							| 
									
										
										
										
											2008-09-11 17:11:16 -07:00
										 |  |  | 0x156a?zi | 
					
						
							|  |  |  | 	sys·panicl(342, 0, 0, ...) | 
					
						
							|  |  |  | 	sys·panicl(0x156, 0x300000000, 0xb024, ...) | 
					
						
							|  |  |  | 0x13c2?zi | 
					
						
							|  |  |  | 	main·main(1, 0, 1606416416, ...) | 
					
						
							|  |  |  | 	main·main(0x1, 0x7fff5fbff820, 0x0, ...) | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* An array composite literal needs to be created freshly every time. | 
					
						
							|  |  |  |    It is a "construction" of an array after all. If I pass the address | 
					
						
							|  |  |  |    of the array to some function, it may store it globally. Same applies | 
					
						
							|  |  |  |    to struct literals. | 
					
						
							|  |  |  | */ |