checkedint call removal

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 15:40:49 PDT 2014


Walter Bright:

>>    void f(ubyte[] a) @safe { assert(a.length>99); a[88] = 
>> a[77]; }
>
> The compiler will insert array bounds checking for you.

But if your "assert" is the same as an assume(), then the 
optimizer should remove bounds checks (otherwise it's a lousy 
implementation of assume()) and leave no tests whatsoever inside 
the function f. So now you now have a safe function that is 
unsafe.

I think you are still missing the essential difference between 
assume and assert.

Bye,
bearophile


More information about the Digitalmars-d mailing list