blob: 9985e5a0ee0f87118674e169b9b1d3f13379d869 [file] [log] [blame]
Shenghou Ma0d6a0d62015-03-11 12:07:50 -04001// run
2
3// Copyright 2015 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// Issue 10135: append a slice with zero-sized element used
8// to always return a slice with the same data pointer as the
9// old slice, even if it's nil, so this program used to panic
10// with nil pointer dereference because after append, s is a
11// slice with nil data pointer but non-zero len and cap.
12
13package main
14
15type empty struct{}
16
17func main() {
18 var s []empty
19
20 s = append(s, empty{})
21
22 for _, v := range s {
23 _ = v
24 }
25}