Source file test/fixedbugs/issue80520.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 //go:noinline 10 func id[T any](x T) T { return x } 11 12 //go:noinline 13 func stale[T any](p *T, v T) T { 14 q := id[*T](p) 15 16 *q = v 17 18 var zero T 19 *p = zero 20 21 return *q 22 } 23 24 var a, b = 7, 9 25 26 func main() { 27 p := &a 28 r := stale[*int](&p, &b) 29 if p != nil { 30 panic("p is not nil") 31 } 32 if r != nil { 33 panic("r is not nil") 34 } 35 } 36