From: Keith Randall Date: Fri, 8 Jul 2016 22:59:00 +0000 (-0700) Subject: cmd/compile: allow unsafe.Pointer(nil) as static data X-Git-Tag: go1.8beta1~1840 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=64214792e214bbacb8c00ffea92a7131e30fa59e;p=gostls13.git cmd/compile: allow unsafe.Pointer(nil) as static data Fixes #16306 Change-Id: If8e2f411fe9a5a5c198f10765fee7261ba8feaf2 Reviewed-on: https://go-review.googlesource.com/24836 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder --- diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go index 72c06dde2d..b564ee0673 100644 --- a/src/cmd/compile/internal/gc/sinit.go +++ b/src/cmd/compile/internal/gc/sinit.go @@ -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 index 0000000000..d29a75a604 --- /dev/null +++ b/test/fixedbugs/issue16306.go @@ -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} +}