[OT] The Usual Arithmetic Confusions

Dukc ajieskola at gmail.com
Thu Feb 3 22:12:10 UTC 2022


On Thursday, 3 February 2022 at 21:36:19 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 3 February 2022 at 21:23:10 UTC, Dukc wrote:
>> We cannot allow undefined behaviour in `@safe` code.
>
> Why not, make it implementation defined, with the requirement 
> that memory safety is upheld by compiled code.

That is a different solution. Implementation defined != undefined.

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.

So you'd have to start defining arbitrary rules on what the 
compiler can and what it cannot do on overflow. Just saying 
"preserve memory safety" does not work, because it depends on 
situation what is necessary for memory safety.

Even without that issue, I would not be supportive. D is old and 
used enough that any changing of overflow semantics of D integers 
is too disruptive to be worth it.



More information about the Digitalmars-d mailing list