mirror of
https://github.com/golang/go
synced 2024-11-05 17:56:13 -07:00
b5b2cf519f
Since when go/types,types2 do not know about build constraints, and runtime/cgo.Incomplete is only available on platforms that support cgo. These tests are also failing on aix with failure from linker, so disable them on aix to make builder green. The fix for aix is tracked in #54814 Updates #46731 Updates #54814 Change-Id: I5d6f6e29a8196efc6c457ea64525350fc6b20309 Reviewed-on: https://go-review.googlesource.com/c/go/+/427394 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
41 lines
882 B
Go
41 lines
882 B
Go
// run
|
|
|
|
// Copyright 2020 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.
|
|
|
|
//go:build cgo && !aix
|
|
|
|
package main
|
|
|
|
import (
|
|
"runtime/cgo"
|
|
"unsafe"
|
|
)
|
|
|
|
type S struct {
|
|
_ cgo.Incomplete
|
|
x int
|
|
}
|
|
|
|
func main() {
|
|
var i int
|
|
p := (*S)(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
|
|
v := uintptr(unsafe.Pointer(p))
|
|
// p is a pointer to a not-in-heap type. Like some C libraries,
|
|
// we stored an integer in that pointer. That integer just happens
|
|
// to be the address of i.
|
|
// v is also the address of i.
|
|
// p has a base type which is marked not-in-heap, so it
|
|
// should not be adjusted when the stack is copied.
|
|
recurse(100, p, v)
|
|
}
|
|
func recurse(n int, p *S, v uintptr) {
|
|
if n > 0 {
|
|
recurse(n-1, p, v)
|
|
}
|
|
if uintptr(unsafe.Pointer(p)) != v {
|
|
panic("adjusted notinheap pointer")
|
|
}
|
|
}
|