Time to move std.experimental.checkedint to std.checkedint ?

Vladimir Panteleev thecybershadow.lists at gmail.com
Wed Mar 31 05:39:11 UTC 2021


On Wednesday, 31 March 2021 at 05:32:16 UTC, Walter Bright wrote:
> On 3/30/2021 10:16 PM, Vladimir Panteleev wrote:
>> 1. The compiler (whether it's the Zig frontend or the LLVM 
>> backend) is smart about adding the checks. If it can prove 
>> that the values will never overflow, then the overflow checks 
>> aren't emitted. I had to trick it into thinking that they may 
>> overflow, when in practice they never will.
>
> The code uses hardcoded loop limits. Yes, the compiler can 
> infer no overflow by knowing the limits of the value. In my 
> experience, I rarely loop for a hardcoded number of times.

Well, this is fake artificial code, and looping a fixed number of 
times is just one aspect of its fakeness. If you do loop an 
unpredictable number of times in your real program, then you 
almost certainly do need the overflow check, so emitting it would 
be the right thing to do there :)



More information about the Digitalmars-d mailing list