On 11/3/2011 1:15 AM, Don wrote:
On 03.11.2011 08:47, knommad wrote:
Hi,
I'm a relative newcomer to D, and am enjoying the experience.
I have a small testcase here that causes what seems to be a spurious
warning
from the compiler (resulting code still works, however).
Am I missing something??
It's an interesting situation that you've found. The foreach is a
static foreach, so it gets unrolled at compile time. In each unrolled
bit, 'member' is a compile-time constant, so the if statement becomes
either true or false. The code is in fact unreachable in that iteration.
So the warning is correct, but arguably not helpful.
Maybe we should suppress unreachable code warnings inside unrolled code.
Isn't this what static if is for?