{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/comments/307719725","pull_request_review_id":267156973,"id":307719725,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMwNzcxOTcyNQ==","diff_hunk":"@@ -38,3 +28,44 @@ contents are.\n Even if the offsets happen to be all 0, there might still be differences in the\n function call ABI.  If you need to pass unions by-value across an FFI boundary,\n you have to use `#[repr(C)]`.\n+\n+### Layout of `repr(C)` unions\n+\n+The layout of `repr(C)` unions follows the C layout scheme. Per sections\n+[6.5.8.5] and [6.7.2.1.16] of the C11 specification, this means that the offset\n+of every field is 0. Unsafe code can cast a pointer to the union to a field type\n+to obtain a pointer to any field, and vice versa. \n+\n+[6.5.8.5]: http://port70.net/~nsz/c/c11/n1570.html#6.5.8p5\n+[6.7.2.1.16]: http://port70.net/~nsz/c/c11/n1570.html#6.7.2.1p16\n+\n+Since all fields are at offset 0, this implies that `repr(C)` unions do not have\n+padding before or in-between their fields. They can, however, have trailing\n+padding (see next example).","path":"reference/src/layout/unions.md","position":null,"original_position":34,"commit_id":"bc72ad6f00ece2088aa1f17a854cbe027055902f","original_commit_id":"fa11cbdb5ed164563be8a2c0224bfd381c2010dc","user":{"login":"RalfJung","id":330628,"node_id":"MDQ6VXNlcjMzMDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/330628?v=4","gravatar_id":"","url":"https://api.github.com/users/RalfJung","html_url":"https://github.com/RalfJung","followers_url":"https://api.github.com/users/RalfJung/followers","following_url":"https://api.github.com/users/RalfJung/following{/other_user}","gists_url":"https://api.github.com/users/RalfJung/gists{/gist_id}","starred_url":"https://api.github.com/users/RalfJung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RalfJung/subscriptions","organizations_url":"https://api.github.com/users/RalfJung/orgs","repos_url":"https://api.github.com/users/RalfJung/repos","events_url":"https://api.github.com/users/RalfJung/events{/privacy}","received_events_url":"https://api.github.com/users/RalfJung/received_events","type":"User","site_admin":false},"body":"Fine for me -- but do you still think my proposed wording doesn't work here if we don't have the picture?","created_at":"2019-07-26T12:27:59Z","updated_at":"2019-07-26T12:28:00Z","html_url":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160#discussion_r307719725","pull_request_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/comments/307719725"},"html":{"href":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160#discussion_r307719725"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160"}},"in_reply_to_id":304019914},"pull_request":{"url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160","id":295355499,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjk1MzU1NDk5","html_url":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160","diff_url":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160.diff","patch_url":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160.patch","issue_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/160","number":160,"state":"open","locked":false,"title":"Detail layout of repr(C) unions","user":{"login":"gnzlbg","id":904614,"node_id":"MDQ6VXNlcjkwNDYxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/904614?v=4","gravatar_id":"","url":"https://api.github.com/users/gnzlbg","html_url":"https://github.com/gnzlbg","followers_url":"https://api.github.com/users/gnzlbg/followers","following_url":"https://api.github.com/users/gnzlbg/following{/other_user}","gists_url":"https://api.github.com/users/gnzlbg/gists{/gist_id}","starred_url":"https://api.github.com/users/gnzlbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnzlbg/subscriptions","organizations_url":"https://api.github.com/users/gnzlbg/orgs","repos_url":"https://api.github.com/users/gnzlbg/repos","events_url":"https://api.github.com/users/gnzlbg/events{/privacy}","received_events_url":"https://api.github.com/users/gnzlbg/received_events","type":"User","site_admin":false},"body":"Documents the behavior described in #156 .","created_at":"2019-07-08T14:14:30Z","updated_at":"2019-07-26T12:28:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ecc673f8aca43aef6653a3176cb1fe59e016121","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160/commits","review_comments_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160/comments","review_comment_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/160/comments","statuses_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/statuses/bc72ad6f00ece2088aa1f17a854cbe027055902f","head":{"label":"gnzlbg:reprc_unions","ref":"reprc_unions","sha":"bc72ad6f00ece2088aa1f17a854cbe027055902f","user":{"login":"gnzlbg","id":904614,"node_id":"MDQ6VXNlcjkwNDYxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/904614?v=4","gravatar_id":"","url":"https://api.github.com/users/gnzlbg","html_url":"https://github.com/gnzlbg","followers_url":"https://api.github.com/users/gnzlbg/followers","following_url":"https://api.github.com/users/gnzlbg/following{/other_user}","gists_url":"https://api.github.com/users/gnzlbg/gists{/gist_id}","starred_url":"https://api.github.com/users/gnzlbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnzlbg/subscriptions","organizations_url":"https://api.github.com/users/gnzlbg/orgs","repos_url":"https://api.github.com/users/gnzlbg/repos","events_url":"https://api.github.com/users/gnzlbg/events{/privacy}","received_events_url":"https://api.github.com/users/gnzlbg/received_events","type":"User","site_admin":false},"repo":{"id":156226973,"node_id":"MDEwOlJlcG9zaXRvcnkxNTYyMjY5NzM=","name":"unsafe-code-guidelines","full_name":"gnzlbg/unsafe-code-guidelines","private":false,"owner":{"login":"gnzlbg","id":904614,"node_id":"MDQ6VXNlcjkwNDYxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/904614?v=4","gravatar_id":"","url":"https://api.github.com/users/gnzlbg","html_url":"https://github.com/gnzlbg","followers_url":"https://api.github.com/users/gnzlbg/followers","following_url":"https://api.github.com/users/gnzlbg/following{/other_user}","gists_url":"https://api.github.com/users/gnzlbg/gists{/gist_id}","starred_url":"https://api.github.com/users/gnzlbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnzlbg/subscriptions","organizations_url":"https://api.github.com/users/gnzlbg/orgs","repos_url":"https://api.github.com/users/gnzlbg/repos","events_url":"https://api.github.com/users/gnzlbg/events{/privacy}","received_events_url":"https://api.github.com/users/gnzlbg/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gnzlbg/unsafe-code-guidelines","description":"Home for the Unsafe Code Guidelines effort.","fork":true,"url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines","forks_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/forks","keys_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/teams","hooks_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/hooks","issue_events_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/events","assignees_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/tags","blobs_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/languages","stargazers_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/stargazers","contributors_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/contributors","subscribers_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/subscribers","subscription_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/subscription","commits_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/issues/comments{/number}","contents_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/merges","archive_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/downloads","issues_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/releases{/id}","deployments_url":"https://api.github.com/repos/gnzlbg/unsafe-code-guidelines/deployments","created_at":"2018-11-05T14:02:03Z","updated_at":"2019-03-19T16:16:04Z","pushed_at":"2019-07-26T12:21:52Z","git_url":"git://github.com/gnzlbg/unsafe-code-guidelines.git","ssh_url":"git@github.com:gnzlbg/unsafe-code-guidelines.git","clone_url":"https://github.com/gnzlbg/unsafe-code-guidelines.git","svn_url":"https://github.com/gnzlbg/unsafe-code-guidelines","homepage":null,"size":261,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"97cbda4bd9f4e5de60a695a0d0bc1862f638ea24","user":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":139737011,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk3MzcwMTE=","name":"unsafe-code-guidelines","full_name":"rust-lang/unsafe-code-guidelines","private":false,"owner":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/rust-lang/unsafe-code-guidelines","description":"Home for the Unsafe Code Guidelines working group.","fork":false,"url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines","forks_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/forks","keys_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/teams","hooks_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/events","assignees_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/tags","blobs_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/languages","stargazers_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/subscription","commits_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/merges","archive_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/downloads","issues_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/deployments","created_at":"2018-07-04T15:06:32Z","updated_at":"2019-07-26T08:31:54Z","pushed_at":"2019-07-26T12:21:53Z","git_url":"git://github.com/rust-lang/unsafe-code-guidelines.git","ssh_url":"git@github.com:rust-lang/unsafe-code-guidelines.git","clone_url":"https://github.com/rust-lang/unsafe-code-guidelines.git","svn_url":"https://github.com/rust-lang/unsafe-code-guidelines","homepage":"https://rust-lang.github.io/unsafe-code-guidelines","size":896,"stargazers_count":162,"watchers_count":162,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":19,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":77,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":19,"open_issues":77,"watchers":162,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160"},"html":{"href":"https://github.com/rust-lang/unsafe-code-guidelines/pull/160"},"issue":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/160"},"comments":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/issues/160/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/pulls/160/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/unsafe-code-guidelines/statuses/bc72ad6f00ece2088aa1f17a854cbe027055902f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"RalfJung"}}