Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
5309fae1
Commit
5309fae1
authored
Aug 31, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: don't assign address of array to slice.
R=rsc CC=golang-dev
https://golang.org/cl/2084042
parent
0f61f014
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
14 additions
and
14 deletions
+14
-14
test/convert3.go
test/convert3.go
+2
-2
test/fixedbugs/bug045.go
test/fixedbugs/bug045.go
+1
-1
test/fixedbugs/bug059.go
test/fixedbugs/bug059.go
+1
-1
test/fixedbugs/bug146.go
test/fixedbugs/bug146.go
+1
-1
test/ken/array.go
test/ken/array.go
+4
-4
test/ken/slicearray.go
test/ken/slicearray.go
+2
-2
test/nilptr/arraytoslice.go
test/nilptr/arraytoslice.go
+1
-1
test/nilptr/arraytoslice1.go
test/nilptr/arraytoslice1.go
+1
-1
test/nilptr/arraytoslice2.go
test/nilptr/arraytoslice2.go
+1
-1
No files found.
test/convert3.go
View file @
5309fae1
...
...
@@ -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
)
...
...
test/fixedbugs/bug045.go
View file @
5309fae1
...
...
@@ -13,7 +13,7 @@ type T struct {
func
main
()
{
var
ta
[]
*
T
;
ta
=
new
([
1
]
*
T
);
ta
=
new
([
1
]
*
T
)
[
0
:
]
;
ta
[
0
]
=
nil
;
}
/*
...
...
test/fixedbugs/bug059.go
View file @
5309fae1
...
...
@@ -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"
;
...
...
test/fixedbugs/bug146.go
View file @
5309fae1
...
...
@@ -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
;
}
test/ken/array.go
View file @
5309fae1
...
...
@@ -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
...
...
test/ken/slicearray.go
View file @
5309fae1
...
...
@@ -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)
...
...
test/nilptr/arraytoslice.go
View file @
5309fae1
...
...
@@ -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
}
test/nilptr/arraytoslice1.go
View file @
5309fae1
...
...
@@ -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
;
}
test/nilptr/arraytoslice2.go
View file @
5309fae1
...
...
@@ -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)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment