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
7package main
8
9import "unsafe"
10
11func main() {
12	var x [2]uint64
13	a := unsafe.Pointer(&x[1])
14
15	b := a
16	b = unsafe.Pointer(uintptr(b) + 2)
17	b = unsafe.Pointer(uintptr(b) - 1)
18	b = unsafe.Pointer(uintptr(b) &^ 1)
19
20	if a != b {
21		panic("pointer arithmetic failed")
22	}
23}
24