You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Empty struct comparison behavior is inconsistent, when fmt.Printf("%p, %p\n", &a, &b) exist &a == &b is true, otherwise the result is false. I think the printf statement shoult not affect the comparison result.
package main
import (
"fmt"
)
func main() {
var a, b struct{}
fmt.Printf("%p, %p\n", &a, &b)
fmt.Println(&a == &b)
// Output:
// 0x585448, 0x585448
// true
var x, y struct{}
fmt.Println(&x == &y)
// Output:
// false
}
What version of Go are you using (go version)?
$ go version
go version go1.15.5 darwin/amd64
Does this issue reproduce with the latest release?
Empty struct comparison behavior is inconsistent, when
fmt.Printf("%p, %p\n", &a, &b)
exist&a == &b
is true, otherwise the result is false. I think the printf statement shoult not affect the comparison result.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes,on play.golang.org got the same result.
https://play.golang.org/p/A-KTgM3J4wQ
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Regardless of whether
fmt.Printf("%p, %p\n", &a, &b)
exists or not, the result should be consistenthttps://play.golang.org/p/A-KTgM3J4wQ
What did you expect to see?
true
true
What did you see instead?
true
false
The text was updated successfully, but these errors were encountered: