diff options
author | Russ Cox <rsc@golang.org> | 2010-02-12 13:59:02 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-02-12 13:59:02 -0800 |
commit | f74385fda538fa91f353e8fb23a0cdda1e15c02f (patch) | |
tree | 89800386c58ed35c132637ac1a81c8c10c6e996b /test/fixedbugs | |
parent | fda831c723dadcd8daa945b685471c7b62d6f0fb (diff) | |
download | go-f74385fda538fa91f353e8fb23a0cdda1e15c02f.tar.gz |
gc: diagnose invalid array bounds
Fixes issue 587.
R=ken2
CC=golang-dev
http://codereview.appspot.com/207085
Diffstat (limited to 'test/fixedbugs')
-rw-r--r-- | test/fixedbugs/bug254.go | 16 | ||||
-rw-r--r-- | test/fixedbugs/bug255.go | 15 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/fixedbugs/bug254.go b/test/fixedbugs/bug254.go new file mode 100644 index 000000000..f351eb84e --- /dev/null +++ b/test/fixedbugs/bug254.go @@ -0,0 +1,16 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug254 + +// Copyright 2010 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 + +var a [10]int +var b [1e1]int + +func main() { + if len(a) != 10 || len(b) != 10 { + panicln("len", len(a), len(b)) + } +} diff --git a/test/fixedbugs/bug255.go b/test/fixedbugs/bug255.go new file mode 100644 index 000000000..4003a780c --- /dev/null +++ b/test/fixedbugs/bug255.go @@ -0,0 +1,15 @@ +// errchk $G -e $D/$F.go + +// Copyright 2010 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 + +var a [10]int // ok +var b [1e1]int // ok +var c [1.5]int // ERROR "truncated" +var d ["abc"]int // ERROR "invalid array bound" +var e [nil]int // ERROR "invalid array bound" +var f [e]int // ERROR "invalid array bound" +var g [1<<65]int // ERROR "overflows" |