aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-05-27 21:38:19 -0400
committerRuss Cox <rsc@golang.org>2014-05-27 21:38:19 -0400
commit74ce581b06fc4f0de1c862604830ce312283a7db (patch)
treea7f24f2bd7673c932f3ce03a096e0fd4373095e9
parent3d1c3e1e262d8f6d7ad2be52af7d226a6fb88ccf (diff)
downloadgo-74ce581b06fc4f0de1c862604830ce312283a7db.tar.gz
go-74ce581b06fc4f0de1c862604830ce312283a7db.zip
cmd/gc: fix conversion of runtime constant
The code cannot have worked before, because it was trying to use the old value in a range check for the new type, which might have a different representation (hence the 'internal compiler error'). Fixes #8073. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/98630045
-rw-r--r--src/cmd/gc/const.c1
-rw-r--r--test/fixedbugs/issue8073.go15
2 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index 1b46974581..143c1730d2 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -951,6 +951,7 @@ unary:
case TUP(OCONV, CTFLT):
case TUP(OCONV, CTSTR):
convlit1(&nl, n->type, 1);
+ v = nl->val;
break;
case TUP(OPLUS, CTINT):
diff --git a/test/fixedbugs/issue8073.go b/test/fixedbugs/issue8073.go
new file mode 100644
index 0000000000..6601221104
--- /dev/null
+++ b/test/fixedbugs/issue8073.go
@@ -0,0 +1,15 @@
+// compile
+
+// Copyright 2014 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.
+
+// issue 8073.
+// was "internal compiler error: overflow: float64 integer constant"
+
+package main
+
+func main() {
+ var x int
+ _ = float64(x * 0)
+}