title: Do..while inside switch
body: <p>I found some C code that has this structure:</p>
  
  <pre><code>switch (n) {
    do {
       case 1:
         // do some things
         if (some condition)
            goto go_on;
       case 2:
         // do some things
         if (some condition)
            goto go_on;
       case 3:
         // do some things
         if (some condition)
            goto go_on;
    } while (1);
    do {
       case 4:
         // do some things
         if (some condition)
            goto go_on;
       case 5:
         // do some things
         if (some condition)
            goto go_on;
    } while (1);
  }
  
  go_on:
  </code></pre>
  
  <p>I programmed in C for years (many years ago) and would have thought this would be a syntax error. I think it has something to do with optimizing the loop, but I was wondering if someone could explain what it does. What happens when a <code>while(1)</code> is reached, does it effectively go back to the switch? And in particular why are there two do..while's in there? </p>
  
  <p>By the way, I <em>don't</em> want to start a discussion on the use of <code>goto</code> or if this is bad design. I didn't write this and I assume the author did it this way because it made the loop run as fast as possible.</p>