]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow unsafe.Pointer(nil) as static data
authorKeith Randall <khr@golang.org>
Fri, 8 Jul 2016 22:59:00 +0000 (15:59 -0700)
committerKeith Randall <khr@golang.org>
Tue, 16 Aug 2016 17:47:50 +0000 (17:47 +0000)
Fixes #16306

Change-Id: If8e2f411fe9a5a5c198f10765fee7261ba8feaf2
Reviewed-on: https://go-review.googlesource.com/24836
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/sinit.go
test/fixedbugs/issue16306.go [new file with mode: 0644]

index 72c06dde2d559c0d8a6d705549242ddf6e1a627f..b564ee0673be4125d24f6906af83337128ac0bc2 100644 (file)
@@ -1435,7 +1435,7 @@ func genAsInitNoCheck(n *Node, reportOnly bool) bool {
 
        case TBOOL, TINT8, TUINT8, TINT16, TUINT16,
                TINT32, TUINT32, TINT64, TUINT64,
-               TINT, TUINT, TUINTPTR,
+               TINT, TUINT, TUINTPTR, TUNSAFEPTR,
                TPTR32, TPTR64,
                TFLOAT32, TFLOAT64:
                if !reportOnly {
diff --git a/test/fixedbugs/issue16306.go b/test/fixedbugs/issue16306.go
new file mode 100644 (file)
index 0000000..d29a75a
--- /dev/null
@@ -0,0 +1,15 @@
+// compile
+
+// Copyright 2016 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.
+
+package main
+
+import "unsafe"
+
+var x = unsafe.Pointer(uintptr(0))
+
+func main() {
+       _ = map[unsafe.Pointer]int{unsafe.Pointer(uintptr(0)): 0}
+}