1
0
mirror of https://github.com/golang/go synced 2024-09-23 23:10:13 -06:00
go/misc
Ian Lance Taylor da769814b8 cmd/cgo: handle GCC 8 change in errors about constant initializers
Before GCC 8 C code like

const unsigned long long int neg = (const unsigned long long) -1;
void f(void) { static const double x = (neg); }

would get an error "initializer element is not constant". In GCC 8 and
later it does not.

Because a value like neg, above, can not be used as a general integer
constant, this causes cgo to conclude that it is a floating point
constant. The way that cgo handles floating point values then causes
it to get the wrong value for it: 18446744073709551615 rather than -1.
These are of course the same value when converted to int64, but Go
does not permit that kind of conversion for an out-of-range constant.

This CL side-steps the problem by treating floating point constants
with integer type as they would up being treated before GCC 8: as
variables rather than constants.

Fixes #26066

Change-Id: I6f2f9ac2fa8a4b8218481b474f0b539758eb3b79
Reviewed-on: https://go-review.googlesource.com/121035
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-29 23:22:48 +00:00
..
android misc/android: forward SIGQUIT to the process running on the device 2018-05-23 18:18:39 +00:00
arm all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
cgo cmd/cgo: handle GCC 8 change in errors about constant initializers 2018-06-29 23:22:48 +00:00
chrome/gophertool all: link to https instead of http 2015-07-11 14:36:33 +00:00
git misc/git: Fix non-literal period in pre-commit grep 2016-02-26 19:06:38 +00:00
ios misc/ios: forward SIGQUIT to the iOS program 2018-05-11 16:47:28 +00:00
linkcheck misc/linkcheck: better redirect handling, use meaningful exit code 2013-10-25 17:31:02 +03:00
nacl all: use HTTPS for iana.org links 2018-02-13 18:36:48 +00:00
sortac misc/sortac: add tool to sort the AUTHORS and CONTRIBUTORS files 2015-11-12 17:07:09 +00:00
swig cmd/go: fix swig support and run swig tests during run.bash 2017-11-16 17:19:19 +00:00
trace misc/trace: update trace_viewer_full.html 2018-04-26 20:26:23 +00:00
wasm syscall/js: use stable references to JavaScript values 2018-06-26 16:40:09 +00:00
benchcmp all: use golang.org/x/... import paths 2014-11-10 09:15:57 +11:00
editors all: don't refer to code.google.com/p/go{,-wiki}/ 2015-02-06 14:41:47 +00:00