{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/560","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/560/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/560/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/560/events","html_url":"https://github.com/rust-lang/rfcs/pull/560","id":53689124,"number":560,"title":"Integer overflow","user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"milestone":null,"comments":143,"created_at":"2015-01-07T22:12:51Z","updated_at":"2015-02-03T20:01:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/560","html_url":"https://github.com/rust-lang/rfcs/pull/560","diff_url":"https://github.com/rust-lang/rfcs/pull/560.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/560.patch"},"body":"A simplified version of Gabhor's [\"Scoped Attributes for Integer Overflow\" RFC][rfc].\r\n\r\n[Rendered version.](https://github.com/nikomatsakis/rfcs/blob/integer-overflow/text/0000-integer-overflow.md)\r\n\r\n[rfc]: https://github.com/rust-lang/rfcs/pull/146"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/72722923","html_url":"https://github.com/rust-lang/rfcs/pull/560#issuecomment-72722923","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/560","id":72722923,"user":{"login":"rkjnsn","id":7364197,"avatar_url":"https://avatars.githubusercontent.com/u/7364197?v=3","gravatar_id":"","url":"https://api.github.com/users/rkjnsn","html_url":"https://github.com/rkjnsn","followers_url":"https://api.github.com/users/rkjnsn/followers","following_url":"https://api.github.com/users/rkjnsn/following{/other_user}","gists_url":"https://api.github.com/users/rkjnsn/gists{/gist_id}","starred_url":"https://api.github.com/users/rkjnsn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkjnsn/subscriptions","organizations_url":"https://api.github.com/users/rkjnsn/orgs","repos_url":"https://api.github.com/users/rkjnsn/repos","events_url":"https://api.github.com/users/rkjnsn/events{/privacy}","received_events_url":"https://api.github.com/users/rkjnsn/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T20:01:00Z","updated_at":"2015-02-03T20:01:00Z","body":"> One easy way to lighten that burden would be to allow scoped annotations that explicitly disable overflow checks in some region of the code.\r\n\r\nThis strikes me as the completely incorrect way to go about easing the use of wrapping semantics.\r\n\r\nI can see scoped annotations being useful for security and/or performance reasons. One could then have overflow checking for a given security-critical region, even in release mode (in this case, only panicking if the value is used may be desirable). One could also choose enable overflow checking globally and mark performance-critical sections not to be checked (in this case, one may still want checks in those regions enabled for some debug builds).\r\n\r\nHowever, in both of these cases, the semantics are the same: wrapping is unexpected and an error; it's only the amount of checking that varies. Using scoped annotations to change the *semantic* meaning of operations seems very, very wrong. As you mention, one would have to search all enclosing contexts to determine whether operations were meant to be wrapping, and it still wouldn't be clear if it were for performance reasons (overflow is still incorrect) or algorithmic reasons (overflow is expected). Combined with the other points you make, I would find using scoped annotations to determine whether wrapping is desired to be completely unreasonable.\r\n\r\nSomething like providing special wrapping operators seems like a much better approach, if better ergonomics are needed."}}