{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/1240","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1240/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1240/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1240/events","html_url":"https://github.com/rust-lang/rfcs/pull/1240","id":99551488,"number":1240,"title":"References into repr(packed) structs should be `unsafe`.","user":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-lang","name":"T-lang","color":"bfd4f2"}],"state":"open","locked":false,"assignee":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-08-07T00:32:03Z","updated_at":"2015-08-07T19:55:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1240","html_url":"https://github.com/rust-lang/rfcs/pull/1240","diff_url":"https://github.com/rust-lang/rfcs/pull/1240.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1240.patch"},"body":"[Rendered](https://github.com/huonw/rfcs/blob/repr-packed-unsafe-ref/text/0000-repr-packed-unsafe-ref.md).\r\n\r\ncc rust-lang/rust#27060"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/128814569","html_url":"https://github.com/rust-lang/rfcs/pull/1240#issuecomment-128814569","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1240","id":128814569,"user":{"login":"arcnmx","id":13426784,"avatar_url":"https://avatars.githubusercontent.com/u/13426784?v=3","gravatar_id":"","url":"https://api.github.com/users/arcnmx","html_url":"https://github.com/arcnmx","followers_url":"https://api.github.com/users/arcnmx/followers","following_url":"https://api.github.com/users/arcnmx/following{/other_user}","gists_url":"https://api.github.com/users/arcnmx/gists{/gist_id}","starred_url":"https://api.github.com/users/arcnmx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcnmx/subscriptions","organizations_url":"https://api.github.com/users/arcnmx/orgs","repos_url":"https://api.github.com/users/arcnmx/repos","events_url":"https://api.github.com/users/arcnmx/events{/privacy}","received_events_url":"https://api.github.com/users/arcnmx/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T19:55:14Z","updated_at":"2015-08-07T19:55:14Z","body":"@nikomatsakis \r\n\r\n> This would be a more specific rule, yes. It is harder to enforce because (currently) the type-checking code is platform independent.\r\n\r\nA limited implementation would be to whitelist the types that are guaranteed to be 1-aligned on all architectures, which I believe is anything of size 1 or 0? Which again, may not be guaranteed for many types, but at least u8, (), [_; 0]... bool? Not sure. Could probably be done as an OIBIT marker trait. We can also use OIBIT markers with `#[config(target = \"etc\")]` to make it arch-dependent without introducing target-specific code into the lint / type check itself?\r\n\r\n> This is an interesting pattern, but it seems unfortunate to be forced to insert a dummy field of `()` type\r\n\r\nUnfortunate, sure, but there are *very* few legitimate reasons for doing this if 1-aligned type references are safe and allowed. It was more an example of how to do it if you *really* needed to, without manual pointer offset counting.\r\n\r\n> Also, the value of a reference of type `&()` is undefined (well, it can't be NULL, but other than that...), so I don't know that we would guarantee any particular value for the pointer you are creating there.\r\n\r\nHm, even with `repr(C)`? How about other zero-sized types such as [_; 0], struct X, enum Void { }..? Unfortunate, but makes sense :/"}}