OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug273.go] - Blame information for rev 858

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out
2
 
3
// Copyright 2010 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
// http://code.google.com/p/go/issues/detail?id=589
8
 
9
package main
10
 
11
import "unsafe"
12
 
13
var bug = false
14
 
15
var minus1 = -1
16
var big int64 = 10 | 1<<32
17
 
18
var g1 []int
19
 
20
func shouldfail(f func(), desc string) {
21
        defer func() { recover() }()
22
        f()
23
        if !bug {
24
                println("BUG")
25
                bug = true
26
        }
27
        println("didn't crash: ", desc)
28
}
29
 
30
func badlen() {
31
        g1 = make([]int, minus1)
32
}
33
 
34
func biglen() {
35
        g1 = make([]int, big)
36
}
37
 
38
func badcap() {
39
        g1 = make([]int, 10, minus1)
40
}
41
 
42
func badcap1() {
43
        g1 = make([]int, 10, 5)
44
}
45
 
46
func bigcap() {
47
        g1 = make([]int, 10, big)
48
}
49
 
50
var g3 map[int]int
51
func badmapcap() {
52
        g3 = make(map[int]int, minus1)
53
}
54
 
55
func bigmapcap() {
56
        g3 = make(map[int]int, big)
57
}
58
 
59
var g4 chan int
60
func badchancap() {
61
        g4 = make(chan int, minus1)
62
}
63
 
64
func bigchancap() {
65
        g4 = make(chan int, big)
66
}
67
 
68
const addrBits = unsafe.Sizeof((*byte)(nil))
69
 
70
var g5 chan [1<<15]byte
71
func overflowchan() {
72
        if addrBits == 32 {
73
                g5 = make(chan [1<<15]byte, 1<<20)
74
        } else {
75
                // cannot overflow on 64-bit, because
76
                // int is 32 bits and max chan value size
77
                // in the implementation is 64 kB.
78
                panic(1)
79
        }
80
}
81
 
82
func main() {
83
        shouldfail(badlen, "badlen")
84
        shouldfail(biglen, "biglen")
85
        shouldfail(badcap, "badcap")
86
        shouldfail(badcap1, "badcap1")
87
        shouldfail(bigcap, "bigcap")
88
        shouldfail(badmapcap, "badmapcap")
89
        shouldfail(bigmapcap, "bigmapcap")
90
        shouldfail(badchancap, "badchancap")
91
        shouldfail(bigchancap, "bigchancap")
92
        shouldfail(overflowchan, "overflowchan")
93
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.