]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix conversion of runtime constant
authorRuss Cox <rsc@golang.org>
Wed, 28 May 2014 01:38:19 +0000 (21:38 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 28 May 2014 01:38:19 +0000 (21:38 -0400)
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

src/cmd/gc/const.c
test/fixedbugs/issue8073.go [new file with mode: 0644]

index 1b46974581c143d828bf599b9f710fd5beeef2f8..143c1730d2c48d4fa317891707b2ec0500494bb5 100644 (file)
@@ -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 (file)
index 0000000..6601221
--- /dev/null
@@ -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)
+}