On Monday, 5 March 2018 at 15:48:12 UTC, Timon Gehr wrote:

- Using existing assertions as compiler hints is not necessary. (Without having checked it, I'm sure that LDC/GDC have a more suitable intrinsic for this already.)

As far as I can discern, forcing disabled asserts to give compiler hints has no upsides.

In the simple cases, or in anything that looks like a unittest/testsuite, probably not.

There are likely going to be more aggressive optimizations however if CFA can see that a variable will never be outside a given range, i.e:

int[5] arr;

if (len < 0 || len >= 5)
unreachable(); // in non-release code, this would throw a RangeError.

return arr[len];

From this, we aggressively assume that len is a valid index of arr. Something that happens in optimized non-release builds, but in release builds we must accommodate for the possibility of a range error.

Reply via email to