Skip to content
New issue

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

gccgo: incorrect initialization order #8052

Closed
griesemer opened this issue May 20, 2014 · 5 comments
Closed

gccgo: incorrect initialization order #8052

griesemer opened this issue May 20, 2014 · 5 comments

Comments

@griesemer
Copy link
Contributor

$ cat x.go
package main

var (
    a = p("a") + c + b
    b = p("b") + f()
    c = p("c") + f()
    d = p("d") + 3
)

func f() int {
     d++
     return d
}

func p(s string) int {
     println(s)
     return 0
}

func main() {
     println(a, b, c, d)
}

compiling and executing produces:

$ gccgo x.go
$ a.out
d
c
b
a
9 5 4 5

But the correct order per the spec should be: d, b, c, a, with values 9, 4, 5, 5.

See: http://tip.golang.org/ref/spec#Package_initialization
@griesemer
Copy link
Contributor Author

Comment 2:

Fixing this must consider outcome of issue #8485.

@griesemer
Copy link
Contributor Author

Comment 3:

issue #8052 was closed with revision 191f9dc7d039 and this current issue remains a bug
with the new spec.

@ianlancetaylor
Copy link
Contributor

Comment 4:

Is this still a problem?

@paranoiacblack
Copy link
Contributor

Comment 5:

Owner changed to @paranoiacblack.

Status changed to Started.

@paranoiacblack
Copy link
Contributor

Comment 6:

Fixed in
https://code.google.com/p/gofrontend/source/detail?r=96de84075614dd56f47b185977c51d3da147c6a7.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants