-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
package main
import (
"reflect"
"runtime"
)
func f(n int) int {
return n % 2
}
func g(n int) int {
return f(n)
}
func name(fn any) (res string) {
return runtime.FuncForPC(uintptr(reflect.ValueOf(fn).Pointer())).Name()
}
func main() {
println(name(f))
println(name(g))
}
Prints
main.f
main.f
where it should print
main.f
main.g
This happens because the first instruction of g
is an instruction inlined from f
.
This came up recently because the scheduler change https://go-review.googlesource.com/c/go/+/270940 subtly changes the ordering, and line numbering, of assembly instructions at the start of functions.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.