title: Why throw an exception after a switch statement with a default case that returns?
body: <p>The <a href="https://github.com/antirez/redis/blob/3.0/src/ziplist.c#L173" rel="nofollow">Redis Ziplist implementation</a> has a curious convention in one of its functions - a switch statement with a <code>default</code> case followed by an external exception:</p>
  
  <pre><code>static unsigned int zipIntSize(unsigned char encoding) {
      switch(encoding) {
          case ZIP_INT_8B:  return 1;
          case ZIP_INT_16B: return 2;
          case ZIP_INT_24B: return 3;
          case ZIP_INT_32B: return 4;
          case ZIP_INT_64B: return 8;
          default: return 0;
      }
      assert(NULL);
      return 0;
  }
  </code></pre>
  
  <p>Are there compilers that will fail to optimize out the assert and the ending return statement and a circumstance in which the statements would be executed? What is this coding pattern attempting to defend against?</p>