On Mon, Feb 26, 2024 at 11:52 PM tapi...@gmail.com <tapir....@gmail.com> wrote:
> On Tuesday, February 27, 2024 at 3:42:25 PM UTC+8 Jan Mercl wrote: > > On Tue, Feb 27, 2024 at 6:20 AM tapi...@gmail.com <tapi...@gmail.com> > wrote: > > > From common sense, this is an obvious bug. But the spec is indeed not > clear enough. > > It doesn't state whether or not comparisons of pointers to two distinct > zero-size variables should be consistent in a run session. > > Though, from common sense, it should. > > "Pointers to distinct zero-size variables may or may not be equal." > > The outcome is specified to be not predictable. Expecting consistency > means the outcome should be, or eventually become, predictable. That's > the opposite of what the specs say. > > > Then I would argue that the spec never guarantee (x != y) == ! (x == y). > for values of any types (including non-zero-size types). :D > The spec is reasonably clear that guarantee does apply to pointers to non-zero size variables (e.g., non-empty structs). The issue in this discussion thread is limited to the handling of pointers to zero size variables. Precisely because of optimizations the compiler may, or may not, perform regarding the value of such pointers. I would prefer a stronger guarantee regarding pointers to zero size variables, and it looks like a lot of Go users agree with you and me, but that doesn't mean the current behavior is ipso facto broken or useless. Pointers to zero size variables (e.g., empty structs) are a special-case that the Go designers decided to leave ambiguous for now. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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/CABx2%3DD_dBchTJ0LWbRH6j-LLaFz4SBBnwbo_9qFEO4GFfv7asw%40mail.gmail.com.