Skip to content

fmt: println and fmt.Printf returning different results #73063

@pjebs

Description

@pjebs

Go version

1.24 (playground)

Output of go env in your module/workspace:

playground

What did you do?

package main
import (
	"fmt"
	"unsafe"
)
var y func() string = func() string {
	return "sag"
}
func main() {
	println(y)
	fmt.Printf("%p\n", y)
	fmt.Printf("%x", (uintptr)(unsafe.Pointer(&y)))
}

See: https://go.dev/play/p/7K6KJ7TMWXJ

What did you see happen?

0x4be390 <=====
0x492b60 <===== should be the same
559f20

What did you expect to see?

I expected println and fmt.Printf("%p"...) produce the same result.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions