| 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 "runtime" |
| 10 |
|
| 11 |
type T [10]int |
| 12 |
|
| 13 |
var m map[*T]int |
| 14 |
|
| 15 |
//go:noinline |
| 16 |
func 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 |
| 23 |
func V() int { runtime.GC(); runtime.GC(); runtime.GC(); return 123 } |
| 24 |
|
| 25 |
//go:noinline |
| 26 |
func K() *T { |
| 27 |
p := new(T) |
| 28 |
runtime.SetFinalizer(p, func(*T) { println("FAIL") }) |
| 29 |
return p |
| 30 |
} |
| 31 |
|
| 32 |
func main() { |
| 33 |
F() |
| 34 |
} |