ldc doesn't elide bounds check

Kagamin spam at here.lot
Mon Mar 5 19:36:20 UTC 2018


void f(byte[] a, byte[] b)
{
	if(a.length<b.length)b=b[0..a.length];
	foreach(i,c;b)
	{
		a[i]=c;
		if(c==10)break;
	}
}
void g(ulong a, ulong b)
{
	if(a<b)b=a;
	foreach(i;0..b)
	{
		assert(i<=a);
		if(i==10)break;
	}
}

In the function f the code for assert failure is retained, but in 
the function g it disappears at optimization levels -Os and 
above. Is it just me is there some limit for the optimizer?


More information about the digitalmars-d-ldc mailing list