<div dir="ltr"><div><div>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>Of course, I have tried the code with the curly brace in its right position:<br>switch (iC) {<br>        case 1:<br>And the results are the same.<br><br>I have compared the assembly files (.s) and both are the same, disregarding the curly brace position.  <br><br>Could anybody explain why both codes work the same way?  <br><br>I have tried with "Microsoft Visual C 6" and "Microsoft Visual Studio 2010" with the same results.  Also GCC compiles it without any warning (sorry for the version).<br><br></div>Best Regards,<br></div>   Germán Marcos.<br></div>