mirror of
https://github.com/golang/go
synced 2024-11-22 08:54:39 -07:00
test: prepare for 64-bit ints
Minor tweaks to avoid assuming that int is always 32 bits. Update #2188. R=golang-dev, r CC=golang-dev https://golang.org/cl/6553062
This commit is contained in:
parent
3cd890dd5a
commit
0d82e69811
@ -247,10 +247,8 @@ func main() {
|
||||
use(s[ui/1e6])
|
||||
use(a1[ui/1e6])
|
||||
use(a1k[ui/1e6])
|
||||
use(a100k[ui/1e6]) // ERROR "index bounds check elided"
|
||||
use(p1[ui/1e6])
|
||||
use(p1k[ui/1e6])
|
||||
use(p100k[ui/1e6]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i/1e7])
|
||||
use(a1[i/1e7])
|
||||
@ -262,12 +260,7 @@ func main() {
|
||||
|
||||
use(s[ui/1e7])
|
||||
use(a1[ui/1e7])
|
||||
use(a1k[ui/1e7]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui/1e7]) // ERROR "index bounds check elided"
|
||||
use(p1[ui/1e7])
|
||||
use(p1k[ui/1e7]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui/1e7]) // ERROR "index bounds check elided"
|
||||
|
||||
}
|
||||
|
||||
var sum int
|
||||
|
@ -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() {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
package main
|
||||
func main() { // ERROR "stack frame too large"
|
||||
var arr [1000200030]int
|
||||
var arr [1000200030]int32
|
||||
arr_bkup := arr
|
||||
_ = arr_bkup
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user