Walter Bright:
https://github.com/D-Programming-Language/druntime/pull/839
Yes, I know others are interested in this, too!
Just like the safe removal of unnecessary array bound tests, it
is also good to have some logic in the compiler to safely remove
overflow tests. A possible start point is to expose the
expression range values to the library code adding a
__trait(value_range, some_expression).
Here the compiler can remove the overflow check on the sum:
Checked!int x, y;
auto z = (x % 4) + (y % 4);
This makes the checked values faster and will encourage more
people to use them in their code.
Bye,
bearophile