Source file test/fixedbugs/issue35073a.go

     1  // run -gcflags=-d=checkptr
     2  
     3  // Copyright 2020 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test that reflect.Value.UnsafeAddr/Pointer is handled
     8  // correctly by -d=checkptr
     9  
    10  package main
    11  
    12  import (
    13  	"reflect"
    14  	"unsafe"
    15  )
    16  
    17  func main() {
    18  	n := 10
    19  	m := make(map[string]string)
    20  
    21  	_ = unsafe.Pointer(reflect.ValueOf(&n).Elem().UnsafeAddr())
    22  	_ = unsafe.Pointer(reflect.ValueOf(&m).Elem().Pointer())
    23  }
    24  

View as plain text