On 7/30/2014 3:40 PM, bearophile wrote:
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.

That's a good point. You could reasonably argue that such an optimization should not happen.


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

How does assume improve the situation?

Reply via email to