Integer overflow and underflow semantics?

via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 18 21:20:36 PDT 2014


On Friday, 18 July 2014 at 19:02:48 UTC, Walter Bright wrote:
> No, it doesn't, and I don't intend to add them. I believe they 
> cause more trouble than they're worth. That applies to some 
> other optimizations I've also refused to implement, because 
> while legal, they mess up code that most users believe is 
> correct.

But if the compiler can prove that the computation stays within 
the bounds or throws then there is no reason to not allow it. 
Since such optimizations can effect generics performance it would 
be nice to think about ways to help the compiler to establish the 
proof.

Even simple means such as annotating an int type with 
@assume_nowrap or @expect_wrapping etc.


More information about the Digitalmars-d mailing list