diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2015-05-01 19:50:27 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2015-05-07 23:54:28 +0000 |
commit | a3dfcf51c6543ac1af853f1799d70eae83073f1a (patch) | |
tree | 59fd59e123d125c8de6daba8e47904a136153fbe /test/convlit.go | |
parent | 0211d7d7b06216c7c3664ae6ef95c088d5699b8d (diff) | |
download | go-a3dfcf51c6543ac1af853f1799d70eae83073f1a.tar.gz go-a3dfcf51c6543ac1af853f1799d70eae83073f1a.zip |
cmd/internal/gc: unsafe.Pointer constants may only be converted to uintptr
Fixes #8927.
Change-Id: I638cddd439dd2d4eeef5474118cfcbde0c8a5a43
Reviewed-on: https://go-review.googlesource.com/9632
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/convlit.go')
-rw-r--r-- | test/convlit.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/convlit.go b/test/convlit.go index 8a6145d2a0..904e1e63b1 100644 --- a/test/convlit.go +++ b/test/convlit.go @@ -9,6 +9,8 @@ package main +import "unsafe" + // explicit conversion of constants var x1 = string(1) var x2 string = string(1) @@ -18,6 +20,11 @@ var x5 = "a" + string(1) var x6 = int(1e100) // ERROR "overflow" var x7 = float32(1e1000) // ERROR "overflow" +// unsafe.Pointer can only convert to/from uintptr +var _ = string(unsafe.Pointer(uintptr(65))) // ERROR "convert" +var _ = float64(unsafe.Pointer(uintptr(65))) // ERROR "convert" +var _ = int(unsafe.Pointer(uintptr(65))) // ERROR "convert" + // implicit conversions merit scrutiny var s string var bad1 string = 1 // ERROR "conver|incompatible|invalid|cannot" |