[OT] The Usual Arithmetic Confusions
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Feb 3 18:07:43 UTC 2022
On Thursday, 3 February 2022 at 17:33:35 UTC, Dukc wrote:
> If the array is long enough, with semantics you're advocating
> the compiler might reason:
>
> 1. `x` can't overflow, so it must be 0x7FFF at most before the
> multicipation.
> 2. I know `aLongArr` is longer than that, so I can elide the
> bounds check.
>
> Overflows are much less an issue than stuff like that.
I advocated trapping overflows except where you explicitly
disable it. I would also advocate for having both modular
operators and operators that clamp.
More information about the Digitalmars-d
mailing list