Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
test: don't assign address of array to slice.
Browse files Browse the repository at this point in the history
R=rsc
CC=golang-dev
https://golang.org/cl/2084042
  • Loading branch information
ianlancetaylor committed Aug 31, 2010
1 parent 0f61f01 commit 5309fae
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions test/convert3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug045.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type T struct {
func main() {
var ta []*T;

ta = new([1]*T);
ta = new([1]*T)[0:];
ta[0] = nil;
}
/*
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug059.go
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug146.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 4 additions & 4 deletions test/ken/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/ken/slicearray.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/nilptr/arraytoslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion test/nilptr/arraytoslice1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion test/nilptr/arraytoslice2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 5309fae

Please sign in to comment.