[OT] The Usual Arithmetic Confusions
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Feb 3 22:39:05 UTC 2022
On Thursday, 3 February 2022 at 22:12:10 UTC, Dukc wrote:
> With the implementation-defined solution, there is the issue
> that potentially any change may break memory safety. Some other
> functions memory safety may be depending on correct behaviour
> of `@safe` function that has an overflowing integer.
You mean in @trusted code, but then you need to be more specific.
If it actually was an overflow that same argument would can be
made about a wrap-around. Maybe the @trusted code did not expect
a negative value…
If there is an overflow in computing x, then it makes sense that
the value of x is an arbitrary bit-pattern constrained to the
bit-width. You can constrain it further like that if that turns
out to be needed.
Of course, this will only be relevant in @safe code sections
where you disable trapping of overflow.
More information about the Digitalmars-d
mailing list