{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/23719","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/23719/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/23719/comments","events_url":"https://api.github.com/repos/golang/go/issues/23719/events","html_url":"https://github.com/golang/go/issues/23719","id":294736494,"number":23719,"title":"cmd/compile: bad small array comparisons on amd64 since go1.9","user":{"login":"mjl-","id":1684740,"avatar_url":"https://avatars2.githubusercontent.com/u/1684740?v=4","gravatar_id":"","url":"https://api.github.com/users/mjl-","html_url":"https://github.com/mjl-","followers_url":"https://api.github.com/users/mjl-/followers","following_url":"https://api.github.com/users/mjl-/following{/other_user}","gists_url":"https://api.github.com/users/mjl-/gists{/gist_id}","starred_url":"https://api.github.com/users/mjl-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjl-/subscriptions","organizations_url":"https://api.github.com/users/mjl-/orgs","repos_url":"https://api.github.com/users/mjl-/repos","events_url":"https://api.github.com/users/mjl-/events{/privacy}","received_events_url":"https://api.github.com/users/mjl-/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false},{"id":626114820,"url":"https://api.github.com/repos/golang/go/labels/release-blocker","name":"release-blocker","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/62","html_url":"https://github.com/golang/go/milestone/62","labels_url":"https://api.github.com/repos/golang/go/milestones/62/labels","id":2827591,"number":62,"title":"Go1.11","description":"","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":777,"closed_issues":57,"state":"open","created_at":"2017-10-10T13:39:17Z","updated_at":"2018-02-06T13:51:38Z","due_on":"2018-07-31T07:00:00Z","closed_at":null},"comments":6,"created_at":"2018-02-06T12:09:25Z","updated_at":"2018-02-06T14:13:02Z","closed_at":null,"author_association":"NONE","body":"### What version of Go are you using (`go version`)?\r\n\r\n```\r\n$ go1.10rc1 version\r\ngo version go1.10rc1 darwin/amd64\r\n$ go1.9.3 version\r\ngo version go1.9.3 darwin/amd64\r\n$ go1.9 version\r\ngo version go1.9 darwin/amd64\r\n$ go1.8.6 version\r\ngo version go1.8.6 darwin/amd64\r\n```\r\n\r\n### Does this issue reproduce with the latest release?\r\n\r\nyes, and tip\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n\r\n```\r\n$ go env\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOEXE=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"darwin\"\r\nGOOS=\"darwin\"\r\nGOPATH=\"/Users/mjl/go\"\r\nGORACE=\"\"\r\nGOROOT=\"/usr/local/go\"\r\nGOTOOLDIR=\"/usr/local/go/pkg/tool/darwin_amd64\"\r\nGCCGO=\"gccgo\"\r\nCC=\"clang\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/c6/wjpsl76s11l9cn3rv7lzjvq00000gn/T/go-build257631275=/tmp/go-build -gno-record-gcc-switches -fno-common\"\r\nCXX=\"clang++\"\r\nCGO_ENABLED=\"1\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\n```\r\n\r\n### What did you do?\r\n\r\nhttps://play.golang.org/p/JSCb-q6cHiE\r\n\r\ncompare an [2]int32 array.\r\ngo for amd64 incorrectly says they are equal, even if the elements at indices 1 don't match.\r\nlonger/shorter arrays do compare properly.\r\n[2]int64 does compare correctly.\r\nthis only seems broken on amd64, since go1.9.\r\ncompiling with GOARCH=386 gives correct behaviour, same for arm.\r\n\r\n\r\nmore elaborate program with more cases:\r\n\r\n```\r\n$ cat test.go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n)\r\n\r\nfunc main() {\r\n\t// the first one seems wrong, should not be equal\r\n\tfunc() {\r\n\t\tv1 := [2]int32{-102,-102}\r\n\t\tv2 := [2]int32{-102,1126}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n\r\n\tfunc() {\r\n\t\tv1 := [2]int64{-102,-102}\r\n\t\tv2 := [2]int64{-102,1126}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n\r\n\tfunc() {\r\n\t\tv1 := [2]int32{-102, -102}\r\n\t\tv2 := [2]int32{1126, -102}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n\r\n\tfunc() {\r\n\t\tv1 := [3]int32{-102,-102, 1}\r\n\t\tv2 := [3]int32{-102,1126, 2}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n\r\n\tfunc() {\r\n\t\tv1 := [3]int32{-102,-102, 1}\r\n\t\tv2 := [3]int32{-102,-102, 2}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n\r\n\tfunc() {\r\n\t\tv1 := [1]int32{-102}\r\n\t\tv2 := [1]int32{-102}\r\n\t\tfmt.Printf(\"%#v == %#v is %v\\n\", v1, v2, v1 == v2)\r\n\t}()\r\n}\r\n```\r\n\r\n```\r\n$ go1.8.6 run test.go\r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is false\r\n\r\n$ go1.9 run test.go \r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is true\r\n\r\n$ go1.9.3 run test.go\r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is true\r\n\r\n$ go1.10rc1 run test.go\r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is true\r\n\r\n$ /Users/mjl/src/go/bin/go version\r\ngo version devel +fd7331a821 Tue Feb 6 05:00:01 2018 +0000 darwin/amd64\r\n$ /Users/mjl/src/go/bin/go run test.go \r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is true\r\n\r\n\r\n$ GOARCH=386 go1.10rc1 build\r\n$ ./intarraybug \r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is false\r\n\r\npi@raspberrypi$ go version\r\ngo version go1.9.2 linux/arm\r\npi@raspberrypi$ go run test.go \r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is false\r\n```\r\n\r\n\r\n### What did you expect to see?\r\n\r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is false\r\n\r\n\r\n### What did you see instead?\r\n\r\n[2]int32{-102, -102} == [2]int32{-102, 1126} is true\r\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/363433801","html_url":"https://github.com/golang/go/issues/23719#issuecomment-363433801","issue_url":"https://api.github.com/repos/golang/go/issues/23719","id":363433801,"user":{"login":"benpaxton-hf","id":24317933,"avatar_url":"https://avatars1.githubusercontent.com/u/24317933?v=4","gravatar_id":"","url":"https://api.github.com/users/benpaxton-hf","html_url":"https://github.com/benpaxton-hf","followers_url":"https://api.github.com/users/benpaxton-hf/followers","following_url":"https://api.github.com/users/benpaxton-hf/following{/other_user}","gists_url":"https://api.github.com/users/benpaxton-hf/gists{/gist_id}","starred_url":"https://api.github.com/users/benpaxton-hf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benpaxton-hf/subscriptions","organizations_url":"https://api.github.com/users/benpaxton-hf/orgs","repos_url":"https://api.github.com/users/benpaxton-hf/repos","events_url":"https://api.github.com/users/benpaxton-hf/events{/privacy}","received_events_url":"https://api.github.com/users/benpaxton-hf/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T14:13:02Z","updated_at":"2018-02-06T14:13:02Z","author_association":"NONE","body":"Does `conv()` [here](https://github.com/golang/go/commit/3bdc2f3abf0f9cffc8f4e294ef22a23b82e88415#diff-10174ae615db892f5af83f5e6227524bR3386) convert with sign extension? If so, I think that's the issue - if the array is, say, `[2]int8{-3, 2}`, the combined int16 will be `int16(-3) | (int16(2) << 8)`, or 0xFFFD, which is *not* the same as the value of the array read as an int16, which would be `(int16(-3) & 0xFF) | (int16(2) << 8)` or 0x02FD.\r\n\r\nThis would explain why it only happens after a negative element within the same combined integer - if all elements are positive, then the sign extension gives 0s, which is correct."}}
{"actor":{"display_login":"benpaxton-hf"}}