Think the following section should explain the strange behaviour you're seeing:
https://golang.org/ref/spec#Order_of_evaluation

On 19/03/2017 22:59, Jan Mercl wrote:
While trying to resolve a failing (C) test case[0] I encountered a (Go) behavior I do not understand. This code[1]

        package main
        import (
                "fmt"
        )
        var (
                x  = [1]int{2}
                x2 = [1]int{2}
        )
        func foo() int {
                x[0] |= 128
                return 1
        }
        func foo2() int {
                x2[0] |= 128
                return 1
        }
        func main() {
                x[0] |= foo()
                fmt.Println(x[0])
                v := x2[0] | foo2()
                fmt.Println(v)
        }
outputs:

        3
131

It seems to me that the two numbers should be the same. (?)

Thanks in advance to anyone enlightening me.

[0]: https://github.com/gcc-mirror/gcc/blob/4107202e2b8f814f4c63a61b043cfb36a3798de3/gcc/testsuite/gcc.c-torture/execute/pr58943.c
  [1]: https://play.golang.org/p/fGibPFuejQ

--

-j

--
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 <mailto:golang-nuts+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to