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
What does 'go version' print?
go version go1.3.3 linux/amd64
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Get http://play.golang.org/p/mQAu2o6wEb.
2. Uncomment the Println before the if.
3. Run.
What happened?
When compiled as usual, this prints "Not Equals". But when compiled with
-gcflags '-N' it prints "Equals".
What should have happened instead?
It should have printed "Equals" in both cases, as it does when fmt.Println(a)
is commented, or if b is printed as well.
Please provide any additional information below.
The behaviour is the same on Go 1.2. The tip version (go version devel +fb3d6c1631c3 Wed
Oct 15 14:33:52 2014 -0400 linux/amd64) prints "Not Equals" both with
optimisations and without them.
The text was updated successfully, but these errors were encountered:
Per the spec:
"Pointers to distinct zero-size variables may or may not be equal."
(http://tip.golang.org/ref/spec#Comparison_operators)
Technically this is not an error.
Whether or not a given implementation should be consistent with respect to this is a
different question.
Leaving for rsc.
It's not an error, and it has been this way since at least Go 1.1 if not earlier. I
don't think it's worth changing, certainly not now. Don't use equality for pointers to
zero-size values and expect it to mean anything.
I guess we could make all non-nil pointers to zero-size values equal. We can see the
type at compile time.
The text was updated successfully, but these errors were encountered: