1// run
2
3// Copyright 2019 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// Make sure FuncForPC won't panic when given a pc which
8// lies between two functions.
9
10package main
11
12import (
13	"runtime"
14)
15
16func main() {
17	var stack [1]uintptr
18	runtime.Callers(1, stack[:])
19	f() // inlined function, to give main some inlining info
20	for i := uintptr(0); true; i++ {
21		f := runtime.FuncForPC(stack[0] + i)
22		if f.Name() != "main.main" && f.Name() != "main.f" {
23			// Reached next function successfully.
24			break
25		}
26	}
27}
28
29func f() {
30	sink = 0 // one instruction which can't be removed
31}
32
33var sink int
34