Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
d1b14a6f
Commit
d1b14a6f
authored
Jan 25, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: bug247, reported by rob
R=ken2 CC=golang-dev
https://golang.org/cl/194051
parent
fd150e77
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
38 deletions
+60
-38
const.c
src/cmd/gc/const.c
+40
-38
bug247.go
test/fixedbugs/bug247.go
+20
-0
No files found.
src/cmd/gc/const.c
View file @
d1b14a6f
...
...
@@ -330,7 +330,7 @@ evconst(Node *n)
int32
len
;
Strlit
*
str
;
int
wl
,
wr
,
lno
,
et
;
Val
v
;
Val
v
,
rv
;
Mpint
b
;
// pick off just the opcodes that can be
...
...
@@ -424,13 +424,15 @@ evconst(Node *n)
if
(
wl
==
TIDEAL
)
v
=
copyval
(
v
);
rv
=
nr
->
val
;
// since wl == wr,
// the only way v.ctype != nr->val.ctype
// is when one is CTINT and the other CTFLT.
// make both CTFLT.
if
(
v
.
ctype
!=
nr
->
val
.
ctype
)
{
v
=
toflt
(
v
);
nr
->
val
=
toflt
(
nr
->
val
);
rv
=
toflt
(
rv
);
}
// run op
...
...
@@ -445,65 +447,65 @@ evconst(Node *n)
return
;
case
TUP
(
OADD
,
CTINT
):
mpaddfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpaddfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OSUB
,
CTINT
):
mpsubfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpsubfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OMUL
,
CTINT
):
mpmulfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpmulfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
ODIV
,
CTINT
):
if
(
mpcmpfixc
(
nr
->
val
.
u
.
xval
,
0
)
==
0
)
{
if
(
mpcmpfixc
(
rv
.
u
.
xval
,
0
)
==
0
)
{
yyerror
(
"division by zero"
);
mpmovecfix
(
v
.
u
.
xval
,
1
);
break
;
}
mpdivfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpdivfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OMOD
,
CTINT
):
if
(
mpcmpfixc
(
nr
->
val
.
u
.
xval
,
0
)
==
0
)
{
if
(
mpcmpfixc
(
rv
.
u
.
xval
,
0
)
==
0
)
{
yyerror
(
"division by zero"
);
mpmovecfix
(
v
.
u
.
xval
,
1
);
break
;
}
mpmodfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpmodfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OLSH
,
CTINT
):
mplshfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mplshfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
ORSH
,
CTINT
):
mprshfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mprshfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OOR
,
CTINT
):
mporfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mporfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OAND
,
CTINT
):
mpandfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpandfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OANDNOT
,
CTINT
):
mpandnotfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpandnotfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OXOR
,
CTINT
):
mpxorfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
);
mpxorfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
);
break
;
case
TUP
(
OADD
,
CTFLT
):
mpaddfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
);
mpaddfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
break
;
case
TUP
(
OSUB
,
CTFLT
):
mpsubfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
);
mpsubfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
break
;
case
TUP
(
OMUL
,
CTFLT
):
mpmulfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
);
mpmulfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
break
;
case
TUP
(
ODIV
,
CTFLT
):
if
(
mpcmpfltc
(
nr
->
val
.
u
.
fval
,
0
)
==
0
)
{
if
(
mpcmpfltc
(
rv
.
u
.
fval
,
0
)
==
0
)
{
yyerror
(
"division by zero"
);
mpmovecflt
(
v
.
u
.
fval
,
1
.
0
);
break
;
}
mpdivfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
);
mpdivfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
break
;
case
TUP
(
OEQ
,
CTNIL
):
...
...
@@ -512,52 +514,52 @@ evconst(Node *n)
goto
setfalse
;
case
TUP
(
OEQ
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
==
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
==
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
ONE
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
!=
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
!=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OLT
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
<
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
<
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OLE
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
<=
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
<=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OGE
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
>=
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
>=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OGT
,
CTINT
):
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
nr
->
val
.
u
.
xval
)
>
0
)
if
(
mpcmpfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
)
>
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OEQ
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
==
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
==
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
ONE
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
!=
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
!=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OLT
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
<
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
<
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OLE
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
<=
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
<=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OGE
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
>=
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
>=
0
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OGT
,
CTFLT
):
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
nr
->
val
.
u
.
fval
)
>
0
)
if
(
mpcmpfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
)
>
0
)
goto
settrue
;
goto
setfalse
;
...
...
@@ -586,29 +588,29 @@ evconst(Node *n)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OADDSTR
,
CTSTR
):
len
=
v
.
u
.
sval
->
len
+
nr
->
val
.
u
.
sval
->
len
;
len
=
v
.
u
.
sval
->
len
+
rv
.
u
.
sval
->
len
;
str
=
mal
(
sizeof
(
*
str
)
+
len
);
str
->
len
=
len
;
memcpy
(
str
->
s
,
v
.
u
.
sval
->
s
,
v
.
u
.
sval
->
len
);
memcpy
(
str
->
s
+
v
.
u
.
sval
->
len
,
nr
->
val
.
u
.
sval
->
s
,
nr
->
val
.
u
.
sval
->
len
);
memcpy
(
str
->
s
+
v
.
u
.
sval
->
len
,
rv
.
u
.
sval
->
s
,
rv
.
u
.
sval
->
len
);
str
->
len
=
len
;
v
.
u
.
sval
=
str
;
break
;
case
TUP
(
OOROR
,
CTBOOL
):
if
(
v
.
u
.
bval
||
nr
->
val
.
u
.
bval
)
if
(
v
.
u
.
bval
||
rv
.
u
.
bval
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OANDAND
,
CTBOOL
):
if
(
v
.
u
.
bval
&&
nr
->
val
.
u
.
bval
)
if
(
v
.
u
.
bval
&&
rv
.
u
.
bval
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
OEQ
,
CTBOOL
):
if
(
v
.
u
.
bval
==
nr
->
val
.
u
.
bval
)
if
(
v
.
u
.
bval
==
rv
.
u
.
bval
)
goto
settrue
;
goto
setfalse
;
case
TUP
(
ONE
,
CTBOOL
):
if
(
v
.
u
.
bval
!=
nr
->
val
.
u
.
bval
)
if
(
v
.
u
.
bval
!=
rv
.
u
.
bval
)
goto
settrue
;
goto
setfalse
;
}
...
...
test/fixedbugs/bug247.go
0 → 100644
View file @
d1b14a6f
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug247
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
func
main
()
{
const
(
Delta
=
100
*
1e6
Count
=
10
)
_
=
int64
(
Delta
*
Count
)
var
i
interface
{}
=
Count
j
:=
i
.
(
int
)
if
j
!=
Count
{
panicln
(
"j="
,
j
)
}
}
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