https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63812

            Bug ID: 63812
           Summary: Compilation error due to a large floating point
                    constant truncated to integer
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: e29253 at jp dot ibm.com
                CC: cmang at google dot com

GCCGO cannot compile the following program, while GC can compile and run the
same program. This program is derived from a unit test of Docker
(https://github.com/docker/docker/blob/master/pkg/units/size_test.go#L28):

inagaki@black3:~/size_test$ cat example.go
package main

import "fmt"

func main() {
  fmt.Println(int64(2.22*1000000000000000))
}
inagaki@black3:~/size_test$ gccgo example.go
example.go:6:15: error: floating point constant truncated to integer
   fmt.Println(int64(2.22*1000000000000000))
               ^
inagaki@black3:~/size_test$ /usr/bin/go build example.go
inagaki@black3:~/size_test$ ./example
2220000000000000
inagaki@black3:~/size_test$ gccgo --version
gccgo.bin (GCC) 5.0.0 20141029 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

inagaki@black3:~/size_test$

The example can be successfully compiled if the constant value is smaller, for
example, 2.22*10^12.

Reply via email to