Source file src/cmd/cgo/internal/testsanitizers/testdata/asan_global_asm2_fail/main.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import "unsafe"
     8  
     9  var x uint64
    10  
    11  func main() {
    12  	bar(&x)
    13  }
    14  
    15  func bar(a *uint64) {
    16  	p := (*uint64)(unsafe.Add(unsafe.Pointer(a), 1*unsafe.Sizeof(uint64(1))))
    17  	if *p == 10 { // BOOM
    18  		println("its value is 10")
    19  	}
    20  }
    21  

View as plain text