[OT] The Usual Arithmetic Confusions

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Feb 3 21:36:19 UTC 2022


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.

No need to overthink this.

> That means that any integer that would have undefined semantics 
> for overflows could not be used at `@safe`.

It can be left to the compiler by the language standard, but 
still impose generic memory safety requirements on the compiler.

Anyway, I tested overflow with -O3, and it did not remove the 
"bounds check". So there is no reason to believe that the 
optimization passes cannot be tuned in such a way that the 
compiler cannot upheld memory safety.



More information about the Digitalmars-d mailing list