1
0
mirror of https://github.com/golang/go synced 2024-11-17 18:34:44 -07:00
go/test/fixedbugs/issue34966.go
Matthew Dempsky f9226454b9 cmd/compile: fix -d=checkptr for named unsafe.Pointer types
We need to explicitly convert pointers to unsafe.Pointer before
passing to the runtime checkptr instrumentation in case the user
declared their own type with underlying type unsafe.Pointer.

Updates #22218.
Fixes #34966.

Change-Id: I3baa2809d77f8257167cd78f57156f819130baa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/201782
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-10-17 21:10:22 +00:00

15 lines
327 B
Go

// compile -d=checkptr
// Copyright 2019 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 p
import "unsafe"
type ptr unsafe.Pointer
func f(p ptr) *int { return (*int)(p) }
func g(p ptr) ptr { return ptr(uintptr(p) + 1) }