diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-09 14:04:43 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-09 22:18:05 +0000 |
commit | 426ff3746fb2ebb777e32572b6eda5e19263ace9 (patch) | |
tree | e4954deabf3174a41a8f29b34b3ea178d66b3bfd /src/cmd/cgo | |
parent | 73483df406af39e6c244fd2fb90b41c4cfecd51e (diff) | |
download | go-426ff3746fb2ebb777e32572b6eda5e19263ace9.tar.gz go-426ff3746fb2ebb777e32572b6eda5e19263ace9.zip |
cmd/cgo, runtime/cgo: avoid GCC/clang conversion warnings
Add explicit conversions to avoid warnings from -Wsign-conversion and
-Wshorten-64-to-32. Also avoid runtime errors from -fsanitize=undefined.
Fixes #48121
Change-Id: I29dc8d976884fc42826392c10f1e1759bb1a3989
Reviewed-on: https://go-review.googlesource.com/c/go/+/348739
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/cgo')
-rw-r--r-- | src/cmd/cgo/out.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 3badd73f79..ee989b95e5 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -1458,10 +1458,10 @@ const gccProlog = ` (have a negative array count) and an inscrutable error will come out of the compiler and hopefully mention "name". */ -#define __cgo_compile_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; +#define __cgo_compile_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2UL+1UL]; /* Check at compile time that the sizes we use match our expectations. */ -#define __cgo_size_assert(t, n) __cgo_compile_assert_eq(sizeof(t), n, _cgo_sizeof_##t##_is_not_##n) +#define __cgo_size_assert(t, n) __cgo_compile_assert_eq(sizeof(t), (size_t)n, _cgo_sizeof_##t##_is_not_##n) __cgo_size_assert(char, 1) __cgo_size_assert(short, 2) |