{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/12947","labels_url":"https://api.github.com/repos/golang/go/issues/12947/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/12947/comments","events_url":"https://api.github.com/repos/golang/go/issues/12947/events","html_url":"https://github.com/golang/go/issues/12947","id":111530913,"number":12947,"title":"spec: ambiguity in definition of alignment","user":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"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":1043,"closed_issues":131,"state":"open","created_at":"2015-04-06T20:47:19Z","updated_at":"2015-10-16T13:50:06Z","due_on":"2099-12-31T05:00:00Z","closed_at":null},"comments":2,"created_at":"2015-10-15T02:10:59Z","updated_at":"2015-10-16T17:24:30Z","closed_at":null,"body":"The spec (September 24, 2015) says:\r\n\r\n> The following minimal alignment properties are guaranteed:\r\n>\r\n> 1. For a variable x of any type: unsafe.Alignof(x) is at least 1.\r\n> 2. For a variable x of struct type: unsafe.Alignof(x) is the largest of all the values unsafe.Alignof(x.f) for each field f of x, but at least 1.\r\n> 3. For a variable x of array type: unsafe.Alignof(x) is the same as unsafe.Alignof(x[0]), but at least 1.\r\n\r\nWhile intuitive, this definition doesn't address structs with blank fields (because there's no valid x.f expression to access those fields) or zero-element arrays (because x[0] is an illegal expression, as 0 is a constant that's out of the array's bounds).\r\n\r\nIt seems like these can be addressed by changing the wording to something like:\r\n\r\n  1. The alignment of any type is at least 1.\r\n  2. The alignment of a struct type is at least as large as the alignment of each of its fields.\r\n  3. The alignment of an array type is the same as the alignment of its element type.\r\n\r\n(The original definition repeats the \"but at least 1\" wording each time, but that seems redundant since nothing else indicates that rule 1 is mutually exclusive with rules 2 and 3.)"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/148777988","html_url":"https://github.com/golang/go/issues/12947#issuecomment-148777988","issue_url":"https://api.github.com/repos/golang/go/issues/12947","id":148777988,"user":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T17:24:30Z","updated_at":"2015-10-16T17:24:30Z","body":"@griesemer Understood that `unsafe.Alignof` only operates on expressions rather than types (aside: I wish it supported both), but the spec defines \"alignment\" to be a property of types:\r\n\r\n> Computer architectures may require memory addresses to be *aligned*; that is, for addresses of a variable to be a multiple of a factor, the __variable's type's *alignment*__.\r\n\r\nHence why it seems reasonable to me to word alignment guarantees in terms of types too."}}