{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/13901","labels_url":"https://api.github.com/repos/golang/go/issues/13901/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/13901/comments","events_url":"https://api.github.com/repos/golang/go/issues/13901/events","html_url":"https://github.com/golang/go/issues/13901","id":125847460,"number":13901,"title":"cmd/compile: spurious writebarriers emitted for global funcs","user":{"login":"DanielMorsing","id":545573,"avatar_url":"https://avatars.githubusercontent.com/u/545573?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielMorsing","html_url":"https://github.com/DanielMorsing","followers_url":"https://api.github.com/users/DanielMorsing/followers","following_url":"https://api.github.com/users/DanielMorsing/following{/other_user}","gists_url":"https://api.github.com/users/DanielMorsing/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielMorsing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielMorsing/subscriptions","organizations_url":"https://api.github.com/users/DanielMorsing/orgs","repos_url":"https://api.github.com/users/DanielMorsing/repos","events_url":"https://api.github.com/users/DanielMorsing/events{/privacy}","received_events_url":"https://api.github.com/users/DanielMorsing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/6","html_url":"https://github.com/golang/go/milestones/Unplanned","labels_url":"https://api.github.com/repos/golang/go/milestones/6/labels","id":1055141,"number":6,"title":"Unplanned","description":"No plan to fix in any specific release.\r\n","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars.githubusercontent.com/u/104030?v=3","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":1246,"closed_issues":220,"state":"open","created_at":"2015-04-06T20:47:19Z","updated_at":"2016-01-21T19:34:38Z","due_on":"2099-12-31T05:00:00Z","closed_at":null},"comments":2,"created_at":"2016-01-10T21:35:56Z","updated_at":"2016-01-21T21:19:48Z","closed_at":null,"body":"gc emits write barriers when a global function is assigned, even though it is unnecessary\r\n\r\nreproducer:\r\n```\r\npackage foo\r\n\r\ntype t struct {\r\n\tx func() *t\r\n}\r\n\r\nfunc f() *t {\r\n\tg := new(t)\r\n\tg.x = f\r\n\treturn g\r\n}\r\n```\r\nBuilt with `go build -gcflags '-d wb' blah.go`, outputs `./blah.go:9: write barrier`\r\n\r\nI don't think there is any correctness issues with emitting the WB and I doubt the performance suffers for it, but I did get a spurious warning when doing some runtime dev."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/173710976","html_url":"https://github.com/golang/go/issues/13901#issuecomment-173710976","issue_url":"https://api.github.com/repos/golang/go/issues/13901","id":173710976,"user":{"login":"aclements","id":2688315,"avatar_url":"https://avatars.githubusercontent.com/u/2688315?v=3","gravatar_id":"","url":"https://api.github.com/users/aclements","html_url":"https://github.com/aclements","followers_url":"https://api.github.com/users/aclements/followers","following_url":"https://api.github.com/users/aclements/following{/other_user}","gists_url":"https://api.github.com/users/aclements/gists{/gist_id}","starred_url":"https://api.github.com/users/aclements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclements/subscriptions","organizations_url":"https://api.github.com/users/aclements/orgs","repos_url":"https://api.github.com/users/aclements/repos","events_url":"https://api.github.com/users/aclements/events{/privacy}","received_events_url":"https://api.github.com/users/aclements/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T21:19:48Z","updated_at":"2016-01-21T21:19:48Z","body":"Yes, you're right that it's safe to omit this write barrier, since we only care about heap -> heap pointer changes. We have various conditions for omitting write barriers if the slot is not in the heap, but I'm not aware of conditions for omitting write barriers if the pointer being written isn't a heap pointer. @randall77?"}}