<p dir="ltr"><br>
> ><br>
> > Dear colleagues, I have found a strange bit of code that works, but I think it should not.<br>
> ><br>
> > #include <stdio.h><br>
> > int main ()<br>
> > {<br>
> > int iC = 0;<br>
> > for (iC = 1; iC < 5; iC++) {<br>
> > switch (iC)<br>
> > case 1:<br>
> > { // Wrong?, but it works fine!.<br>
> > printf("ONE\n");<br>
> > break;<br>
> > case 2:<br>
> > printf("TWO\n");<br>
> > break;<br>
> > default:<br>
> > printf("NO!\n");<br>
> > break;<br>
> > }<br>
> > }<br>
> > return 0;<br>
> > }<br>
> ><br>
> > The code compiles without any warning using clang 3.4.1 (FreeBSD 10.1) and "-Wall" "--pedantic". And the execution results are:<br>
> > ONE<br>
> > TWO<br>
> > NO!<br>
> > NO!<br>
><br>
> You might want to google “Duff’s Device”<br>
><br>
> — Marshall<br>
><br>
Thanks a lot!<br>
</p>