Source file test/fixedbugs/issue80517_1.go

     1  // run
     2  
     3  // Copyright 2026 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  const targetPC = uintptr(0xdeadbeef)
    10  
    11  type payload struct {
    12  	x uintptr
    13  	y *uintptr
    14  	fn   [2]func()
    15  }
    16  
    17  var p payload
    18  var v []byte
    19  
    20  func init() {
    21  	p.x = targetPC
    22  	p.y = &p.x
    23  	p.fn[0] = func() {}
    24  	p.fn[1] = func() {}
    25  }
    26  
    27  //go:noinline
    28  func trigger(n int) {
    29  	defer func() { recover() }()
    30  
    31  	if n < len(p.fn) {
    32  		p.fn[n&1]()
    33  
    34  		s := make([]byte, n)
    35  		v = s
    36  	}
    37  }
    38  
    39  func main() {
    40  	trigger(-1)
    41  }
    42  

View as plain text