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 7package main 8 9import "runtime" 10 11type T [10]int 12 13var m map[*T]int 14 15//go:noinline 16func F() { 17 m = map[*T]int{ 18 K(): V(), // the key temp should be live across call to V 19 } 20} 21 22//go:noinline 23func V() int { runtime.GC(); runtime.GC(); runtime.GC(); return 123 } 24 25//go:noinline 26func K() *T { 27 p := new(T) 28 runtime.SetFinalizer(p, func(*T) { println("FAIL") }) 29 return p 30} 31 32func main() { 33 F() 34} 35