We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.17 linux/amd64
Reproduced up to 1.14.12.
https://play.golang.org/p/XWirTpyJaDH
var ( a = &struct{}{} b = &struct{}{} ) fmt.Printf("%p %p %t\n", a, b, a == b)
Prints something like 0x555f30 0x555f30 true. Replacing the Printf with
0x555f30 0x555f30 true
fmt.Printf("%p %t\n", a, a == b)
prints 0x555f30 false.
0x555f30 false
Changing to a non-empty struct like struct { a int } makes the issue go away.
struct { a int }
a != b
a == b
The text was updated successfully, but these errors were encountered:
https://golang.org/ref/spec#Comparison_operators
Pointers to distinct zero-size variables may or may not be equal.
The behavior you are observing while strange is fully compliant with the language specification.
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Reproduced up to 1.14.12.
What did you do?
https://play.golang.org/p/XWirTpyJaDH
Prints something like
0x555f30 0x555f30 true
. Replacing the Printf withprints
0x555f30 false
.Changing to a non-empty struct like
struct { a int }
makes the issue go away.What did you expect to see?
a != b
a == b
The text was updated successfully, but these errors were encountered: