]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test: don't assign address of array to slice.
authorIan Lance Taylor <iant@golang.org>
Tue, 31 Aug 2010 14:34:01 +0000 (07:34 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 31 Aug 2010 14:34:01 +0000 (07:34 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/2084042

test/convert3.go
test/fixedbugs/bug045.go
test/fixedbugs/bug059.go
test/fixedbugs/bug146.go
test/ken/array.go
test/ken/slicearray.go
test/nilptr/arraytoslice.go
test/nilptr/arraytoslice1.go
test/nilptr/arraytoslice2.go

index 5f1f0dd94e68f06c5923b03cf157d42d29dae809..be68c95b36207e4278ebbde3e3045efb1f127eb4 100644 (file)
@@ -13,8 +13,8 @@ var d1 chan<- int = c
 var d2 = (chan<- int)(c)
 
 var e *[4]int
-var f1 []int = e
-var f2 = []int(e)
+var f1 []int = e[0:]
+var f2 = []int(e[0:])
 
 var g = []int(nil)
 
index d8a712c6dab0cf47f65bd25b4684850220185abf..94888c40e2e381d42d79f34aa19d299cf8aa9c14 100644 (file)
@@ -13,7 +13,7 @@ type T struct {
 func main() {
        var ta []*T;
 
-       ta = new([1]*T);
+       ta = new([1]*T)[0:];
        ta[0] = nil;
 }
 /*
index b190d4f26d5788ebeb5b61c728c8683b62c8615f..6a77367d6765abcf63a3ba3895eb06f88187bc29 100644 (file)
@@ -25,7 +25,7 @@ func main() {
        as := new([2]string);
        as[0] = "0";
        as[1] = "1";
-       m["0"] = as;
+       m["0"] = as[0:];
 
        a := m["0"];
        a[0] = "x";
index bfb7529d6a793a35bf6c7c0aa42a2c80e308177e..16324c741a4d6a5df6bf59d0580cfaa972de4814 100644 (file)
@@ -9,7 +9,7 @@ package main
 func main() {
        type Slice []byte;
        a := [...]byte{ 0 };
-       b := Slice(&a);         // This should be OK.
+       b := Slice(a[0:]);      // This should be OK.
        c := Slice(a);          // ERROR "invalid|illegal|cannot"
        _, _ = b, c;
 }
index 7785cdf8f6ecee032fea01d4f344ee4d3b21af2a..40209f5da377a5632a921832c9db64108293b46b 100644 (file)
@@ -81,8 +81,8 @@ func testpfpf() {
 // call ptr dynamic with ptr fixed from new
 func testpdpf1() {
        a := new([40]int)
-       setpd(a)
-       res(sumpd(a), 0, 40)
+       setpd(a[0:])
+       res(sumpd(a[0:]), 0, 40)
 
        b := (*a)[5:30]
        res(sumpd(b), 5, 30)
@@ -92,8 +92,8 @@ func testpdpf1() {
 func testpdpf2() {
        var a [80]int
 
-       setpd(&a)
-       res(sumpd(&a), 0, 80)
+       setpd(a[0:])
+       res(sumpd(a[0:]), 0, 80)
 }
 
 // generate bounds error with ptr dynamic
index 76ec809310832fc8004ed0afee443eff60bd13ed..536bbf56b31c04060565f69a39e776513b58da3f 100644 (file)
@@ -16,12 +16,12 @@ var t int
 func main() {
        lb = 0
        hb = 10
-       by = &bx
+       by = bx[0:]
        tstb()
 
        lb = 0
        hb = 10
-       fy = &fx
+       fy = fx[0:]
        tstf()
 
        // width 1 (byte)
index 65b2f8a765e7783ee341869e0597a7bd65c2badc..06c862d0d951a0d884e18f5056c2e5c5cbd07f5e 100644 (file)
@@ -33,5 +33,5 @@ func main() {
        // usual len and cap, we require the *array -> slice
        // conversion to do the check.
        var p *[1<<30]byte = nil;
-       f(p);   // should crash
+       f(p[0:]);       // should crash
 }
index b5240a803a9f963536a345055c04ed2dca4e0c31..286572a4d24c704372dc93bab6e19d4f4cf6b4cf 100644 (file)
@@ -29,6 +29,6 @@ func main() {
        // usual len and cap, we require the *array -> slice
        // conversion to do the check.
        var p *[1<<30]byte = nil;
-       var x []byte = p;       // should crash
+       var x []byte = p[0:];   // should crash
        _ = x;
 }
index 38e1a5cb2821034eec45d225b73d9550b0ff376d..4ac97f13e8f1f5e20ddff369c97e909aa38d20de 100644 (file)
@@ -31,5 +31,5 @@ func main() {
        // conversion to do the check.
        var x []byte;
        var y = &x;
-       *y = q; // should crash (uses arraytoslice runtime routine)
+       *y = q[0:];     // should crash (uses arraytoslice runtime routine)
 }