{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/16769","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/16769/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/16769/comments","events_url":"https://api.github.com/repos/golang/go/issues/16769/events","html_url":"https://github.com/golang/go/issues/16769","id":171722140,"number":16769,"title":"cmd/compile: incorrect assignment to uint64 via pointer converted to *uint16 (new in 1.7)","user":{"login":"kelseyfrancis","id":333244,"avatar_url":"https://avatars.githubusercontent.com/u/333244?v=3","gravatar_id":"","url":"https://api.github.com/users/kelseyfrancis","html_url":"https://github.com/kelseyfrancis","followers_url":"https://api.github.com/users/kelseyfrancis/followers","following_url":"https://api.github.com/users/kelseyfrancis/following{/other_user}","gists_url":"https://api.github.com/users/kelseyfrancis/gists{/gist_id}","starred_url":"https://api.github.com/users/kelseyfrancis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelseyfrancis/subscriptions","organizations_url":"https://api.github.com/users/kelseyfrancis/orgs","repos_url":"https://api.github.com/users/kelseyfrancis/repos","events_url":"https://api.github.com/users/kelseyfrancis/events{/privacy}","received_events_url":"https://api.github.com/users/kelseyfrancis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/44","html_url":"https://github.com/golang/go/milestones/Go1.7.1","labels_url":"https://api.github.com/repos/golang/go/milestones/44/labels","id":1944056,"number":44,"title":"Go1.7.1","description":"Things to backport from tip to Go 1.7.1","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":4,"state":"open","created_at":"2016-08-16T04:14:40Z","updated_at":"2016-08-17T20:41:58Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2016-08-17T18:02:47Z","updated_at":"2016-08-18T15:10:08Z","closed_at":null,"body":"#### What version of Go are you using (`go version`)?\r\n\r\n`go version go1.7 darwin/amd64` and `go version go1.7 linux/amd64`.\r\n\r\nThis issue is not present in `go1.6.2`.\r\n\r\n#### What operating system and processor architecture are you using (`go env`)?\r\n\r\n```\r\nGOARCH=\"amd64\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"darwin\"\r\nGOOS=\"darwin\"\r\n```\r\n\r\nand\r\n\r\n```\r\nGOARCH=\"amd64\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\n```\r\n\r\n#### What did you do?\r\n\r\nAssign a `uint16` (or `uint32`) to a previously unused `uint64` via converted pointer on a little-endian architecture. `go run` the following program:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"fmt\"\r\n    \"unsafe\"\r\n)\r\n\r\nfunc main() {\r\n\tvar x uint64\r\n\t*(*uint16)(unsafe.Pointer(&x)) = 0xffee\r\n\tfmt.Printf(\"%x\\n\", x)\r\n\r\n\tvar y uint64\r\n\tfmt.Printf(\"%x\\n\", y)\r\n\t*(*uint16)(unsafe.Pointer(&y)) = 0xffee\r\n\tfmt.Printf(\"%x\\n\", y)\r\n}\r\n```\r\n\r\n#### What did you expect to see?\r\n\r\n```\r\nffee\r\n0\r\nffee\r\n```\r\n\r\n#### What did you see instead?\r\n\r\n```\r\nc42000ffee\r\n0\r\nffee\r\n```\r\n\r\n\r\nA test that passes with Go 1.6 but not with Go 1.7:\r\n\r\n```go\r\n// +build amd64\r\n\r\npackage main\r\n\r\nimport (\r\n    \"fmt\"\r\n    \"unsafe\"\r\n)\r\n\r\nfunc ExampleUint16NoAccessBeforeAssignment() {\r\n\tvar x uint64\r\n\t*(*uint16)(unsafe.Pointer(&x)) = 0xffee\r\n\tfmt.Printf(\"%x\\n\", x)\r\n    // Output:\r\n    // ffee\r\n}\r\n\r\nfunc ExampleUint16AccessBeforeAssignment() {\r\n\tvar x uint64\r\n\tfmt.Printf(\"%x\\n\", x)\r\n\t*(*uint16)(unsafe.Pointer(&x)) = 0xffee\r\n\tfmt.Printf(\"%x\\n\", x)\r\n    // Output:\r\n    // 0\r\n    // ffee\r\n}\r\n\r\nfunc ExampleUint32NoAccessBeforeAssignment() {\r\n\tvar x uint64\r\n\t*(*uint32)(unsafe.Pointer(&x)) = 0xffeeddcc\r\n\tfmt.Printf(\"%x\\n\", x)\r\n    // Output:\r\n    // ffeeddcc\r\n}\r\n\r\nfunc ExampleUint32AccessBeforeAssignment() {\r\n\tvar x uint64\r\n\tfmt.Printf(\"%x\\n\", x)\r\n\t*(*uint32)(unsafe.Pointer(&x)) = 0xffeeddcc\r\n\tfmt.Printf(\"%x\\n\", x)\r\n    // Output:\r\n    // 0\r\n    // ffeeddcc\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/240753922","html_url":"https://github.com/golang/go/issues/16769#issuecomment-240753922","issue_url":"https://api.github.com/repos/golang/go/issues/16769","id":240753922,"user":{"login":"dr2chase","id":1928999,"avatar_url":"https://avatars.githubusercontent.com/u/1928999?v=3","gravatar_id":"","url":"https://api.github.com/users/dr2chase","html_url":"https://github.com/dr2chase","followers_url":"https://api.github.com/users/dr2chase/followers","following_url":"https://api.github.com/users/dr2chase/following{/other_user}","gists_url":"https://api.github.com/users/dr2chase/gists{/gist_id}","starred_url":"https://api.github.com/users/dr2chase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dr2chase/subscriptions","organizations_url":"https://api.github.com/users/dr2chase/orgs","repos_url":"https://api.github.com/users/dr2chase/repos","events_url":"https://api.github.com/users/dr2chase/events{/privacy}","received_events_url":"https://api.github.com/users/dr2chase/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T15:10:08Z","updated_at":"2016-08-18T15:10:08Z","body":"If we're revising the documentation for unsafe, can we make it a lot scarier and with even fewer things that look like promises?"}}
{"actor":{"display_login":"dr2chase"}}