My concern in this question is not where the bug is but rather why the compiler responds to this bug this particular way. The bug is in case k==4 in the first loop.