summaryrefslogtreecommitdiff
path: root/test/fixedbugs/bug273.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-09-24 00:06:41 -0400
committerRuss Cox <rsc@golang.org>2012-09-24 00:06:41 -0400
commit02951f13e2b9b87f5a27f111ca3b3793ab839008 (patch)
tree0c2657695d39c415b4b9ae5aed5d1e9afc80e6e4 /test/fixedbugs/bug273.go
parent7ea1eaee177e135dcaa14f3b3750c2cda7fa23ba (diff)
downloadgo-02951f13e2b9b87f5a27f111ca3b3793ab839008.tar.gz
test: prepare for 64-bit ints
Minor tweaks to avoid assuming that int is always 32 bits. Update issue 2188. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/6553062
Diffstat (limited to 'test/fixedbugs/bug273.go')
-rw-r--r--test/fixedbugs/bug273.go42
1 files changed, 17 insertions, 25 deletions
diff --git a/test/fixedbugs/bug273.go b/test/fixedbugs/bug273.go
index b35b17d2e..c5e73e945 100644
--- a/test/fixedbugs/bug273.go
+++ b/test/fixedbugs/bug273.go
@@ -8,14 +8,14 @@
package main
-import "unsafe"
-
var bug = false
var minus1 = -1
var big int64 = 10 | 1<<32
-var g1 []int
+type block [1<<19]byte
+
+var g1 []block
func shouldfail(f func(), desc string) {
defer func() { recover() }()
@@ -28,55 +28,47 @@ func shouldfail(f func(), desc string) {
}
func badlen() {
- g1 = make([]int, minus1)
+ g1 = make([]block, minus1)
}
func biglen() {
- g1 = make([]int, big)
+ g1 = make([]block, big)
}
func badcap() {
- g1 = make([]int, 10, minus1)
+ g1 = make([]block, 10, minus1)
}
func badcap1() {
- g1 = make([]int, 10, 5)
+ g1 = make([]block, 10, 5)
}
func bigcap() {
- g1 = make([]int, 10, big)
+ g1 = make([]block, 10, big)
}
-var g3 map[int]int
+var g3 map[block]block
func badmapcap() {
- g3 = make(map[int]int, minus1)
+ g3 = make(map[block]block, minus1)
}
func bigmapcap() {
- g3 = make(map[int]int, big)
+ g3 = make(map[block]block, big)
}
-var g4 chan int
+type cblock [1<<16-1]byte
+
+var g4 chan cblock
func badchancap() {
- g4 = make(chan int, minus1)
+ g4 = make(chan cblock, minus1)
}
func bigchancap() {
- g4 = make(chan int, big)
+ g4 = make(chan cblock, big)
}
-const addrBits = unsafe.Sizeof((*byte)(nil))
-
-var g5 chan [1<<15]byte
func overflowchan() {
- if addrBits == 32 {
- g5 = make(chan [1<<15]byte, 1<<20)
- } else {
- // cannot overflow on 64-bit, because
- // int is 32 bits and max chan value size
- // in the implementation is 64 kB.
- panic(1)
- }
+ g4 = make(chan cblock, 1<<30)
}
func main() {