The comparison in this code
int[] arr;
void main()
{
if (arr != null)
{
arr = [1];
}
}
gets lowered to
!arr.length && !memcmp(arr.ptr, null, arr.length)
The optimizer should be able to tell that the memcmp would always return 0 and skip the check.
Ok, I'll have a look. This can probably be special-cased, although there is a long-standing problem that the optimizer doesn't look at constant data correctly.
Comment #7 by github-bugzilla — 2015-06-17T21:04:40Z