Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: wrong evaluation order for map assignment [Go1.8] #22881
This should print 0, not 1. The nil ptr panic should happen before the insert into m.
The bug goes away if I do
I'm going to label this as a backportable 1.9.3 issue so we can discuss (and maybe also 1.8.6, but github won't let me multi-milestone an issue), but I kind of lean toward just fixing this in 1.10. It's pretty esoteric, survived more than a release cycle without a bug report, and it is easy to work around.
It's also possible I'm not reading the spec correctly, and this is allowed behavior. @griesemer
Doesn't seem to be SSA related - the AST already has the ops out of order on input to SSA.
referenced this issue
Dec 5, 2017
Similar to this problem: https://groups.google.com/forum/#!topic/golang-nuts/J3kXXZivlHA
@go101 The order of evaluation rules are at https://golang.org/ref/spec#Order_of_evaluation. There is no specified order between the function call on the left hand side and the indirection on the right hand side. It's clear that the indirection must happen before the assignment, but there is no requirement that the indirection happen before the function call.