Source file test/fixedbugs/issue48536.go

     1  // run
     2  
     3  // Copyright 2021 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  package main
     8  
     9  import "unsafe"
    10  
    11  var i = 257
    12  
    13  func main() {
    14  	var buf [10]byte
    15  	p0 := unsafe.Pointer(&buf[0])
    16  	p1 := unsafe.Pointer(&buf[1])
    17  
    18  	if p := unsafe.Add(p0, uint8(i)); p != p1 {
    19  		println("FAIL:", p, "!=", p1)
    20  	}
    21  
    22  	var x uint8
    23  	if i != 0 {
    24  		x = 1
    25  	}
    26  	if p := unsafe.Add(p0, x); p != p1 {
    27  		println("FAIL:", p, "!=", p1)
    28  	}
    29  }
    30  

View as plain text