{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/14432","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/14432/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/14432/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/14432/events","html_url":"https://github.com/JuliaLang/julia/pull/14432","id":122815631,"number":14432,"title":"Implement unchecked integer arithmetic","user":{"login":"eschnett","id":213514,"avatar_url":"https://avatars.githubusercontent.com/u/213514?v=3","gravatar_id":"","url":"https://api.github.com/users/eschnett","html_url":"https://github.com/eschnett","followers_url":"https://api.github.com/users/eschnett/followers","following_url":"https://api.github.com/users/eschnett/following{/other_user}","gists_url":"https://api.github.com/users/eschnett/gists{/gist_id}","starred_url":"https://api.github.com/users/eschnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eschnett/subscriptions","organizations_url":"https://api.github.com/users/eschnett/orgs","repos_url":"https://api.github.com/users/eschnett/repos","events_url":"https://api.github.com/users/eschnett/events{/privacy}","received_events_url":"https://api.github.com/users/eschnett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-12-17T20:20:32Z","updated_at":"2015-12-19T16:38:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/14432","html_url":"https://github.com/JuliaLang/julia/pull/14432","diff_url":"https://github.com/JuliaLang/julia/pull/14432.diff","patch_url":"https://github.com/JuliaLang/julia/pull/14432.patch"},"body":"For each basic integer arithmetic operation (abs, negation, +, -, \\*, div, rem, fld, mod, cld), introduce a respective unchecked_* function that performs no overflow checking, and that signals to LLVM that no overflow can occur via the respective NSW and NUW flags. When these functions are used, it is the responsibility of the caller to ensure that these properties hold. For correct code (i.e. where the respective checked_* functions do not report an error), the results are identical to these checked_* functions.\r\n\r\n- Introduce intrinsics for respective LLVM intrinsics\r\n- Add new file `base/unchecked.jl`\r\n- Add documentation\r\n- Add test cases"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/166001998","html_url":"https://github.com/JuliaLang/julia/pull/14432#issuecomment-166001998","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/14432","id":166001998,"user":{"login":"eschnett","id":213514,"avatar_url":"https://avatars.githubusercontent.com/u/213514?v=3","gravatar_id":"","url":"https://api.github.com/users/eschnett","html_url":"https://github.com/eschnett","followers_url":"https://api.github.com/users/eschnett/followers","following_url":"https://api.github.com/users/eschnett/following{/other_user}","gists_url":"https://api.github.com/users/eschnett/gists{/gist_id}","starred_url":"https://api.github.com/users/eschnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eschnett/subscriptions","organizations_url":"https://api.github.com/users/eschnett/orgs","repos_url":"https://api.github.com/users/eschnett/repos","events_url":"https://api.github.com/users/eschnett/events{/privacy}","received_events_url":"https://api.github.com/users/eschnett/received_events","type":"User","site_admin":false},"created_at":"2015-12-19T16:38:35Z","updated_at":"2015-12-19T16:38:35Z","body":"@JeffreySarnoff There are many unsafe functions in Base. Out of curiosity, I skimmed through the code and collected some of them. (These functions are all there for a good reason.)\r\n\r\n- `@inbounds` (array access)\r\n- `@simd` (allows LLVM to rearrange loops in certain ways)\r\n- `ccall` (obviously)\r\n- `@label`, `@goto`\r\n- `deserialize` (unless the input is either explicitly sanitized or cryptographically signed)\r\n- `pointer_to_array`, `pointer_to_string`\r\n- pointer arithmetic (if the pointer value is used later on)\r\n\r\nIt goes without saying that these low-level operations are inherently unsafe:\r\n- `lock`, `unlock`, `acquire` (since any program error when handling locks can lead to data corruption and security faults)\r\n- Anything regarding `Mmap`\r\n- `SharedArray`\r\n\r\nFurthermore, these are unsafe in a multi-tasking environment:\r\n- `cd`, `setenv`, `unsetenv` (they modify global state and interact badly with Julia's tasks)\r\n"}}