-
-
Notifications
You must be signed in to change notification settings - Fork 17k
Per-module control of overflow checks? #70358
Copy link
Copy link
Open
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
Activity
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
For arithmetic that happens inside Miri, I am quite paranoid that we may have an overflow issue, so I spent a lot of time last week-end to go over every occurrence of
+/-/*and replace them all bychecked_*operations. That has not made code more readable, and I am worried I might have missed some cases.I am not sure if enabling overflow checks for all of rustc is realistic, so it would be great if that could be controlled on a per-module level: if I could set something like
#![enable_overflow_checks]in the interpreter modules, I could sleep much more soundly as I would be sure we'd not have silently overflowing arithmetic -- and I wouldn't have to make the code unreadable by turning(x * 2) + 1intox.checked_mul(2).unwrap().checked_add(1).unwrap().Overflow checks are embedded into MIR, and it seems entirely possible to take module-level attributes into account during MIR building, so I think this is realistic.
(I am not sure if this should go into this repo or the RFC repo, feel free to move around.)