https://go.dev/ref/spec#Comparison_operators
• Pointer types are comparable. Two pointer values are equal if they point to the same variable or if both have value nil. Pointers to distinct zero-size variables may or may not be equal. Another example (Go Playground <https://go.dev/play/p/3uPH3rAG2XN>): func f4() { var ( a struct{} b int aa = (*int)(unsafe.Pointer(&a)) ba = (*int)(unsafe.Pointer(&b)) eq = aa == ba ) println("&a:", aa, reflect.TypeOf(aa).String()) println("&b:", ba, reflect.TypeOf(ba).String()) println("&a == &b:", eq) } &a: 0xc0000466f8 *int &b: 0xc0000466f8 *int &a == &b: false We do not have “pointers to distinct zero-size variables”, only one pointer derived from a pointer to a zero-sized variable. I don’t want to be stubborn. What would be the issue with at least adding a FAQ entry? I could open a PR suggesting something, although I’m not a native speaker and might not exactly hit the tone of the document. > Am 20.06.2024 um 12:37 schrieb Jan Mercl <0xj...@gmail.com>: > > On Thu, Jun 20, 2024 at 12:28 PM Oliver Eikemeier > <eikeme...@fillmore-labs.com> wrote: > >> It mentions “pointers” (plural) to zero-sized variables, but for this >> behavior it is sufficient when only one pointer derives from a pointer to a >> zero-sized variable, as demonstrated in the example below. > > The plural is there because the specification discusses all such > pointers, not a particular case. > > The wording is IMO correct and clear. All/any pointers (plural) to > zero sized objects may produce any/unpredictable result in comparison > operations. Relying on the outcome is a bug, because the specs > explicitly say otherwise. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/C02D6616-0B77-4F6F-8597-EFA355BF17E1%40fillmore-labs.com.