title: Unreachable code: error or warning?
body: <p>This is a language design question:</p>
  
  <p>Do you think <strong>unreachable code</strong> (in programming languages in general) should raise a <strong>warning</strong> (i.e. "report problem and compile anyway") or an <strong>error</strong> ("refuse to compile")?</p>
  
  <p>Personally I strongly feel it should be an error: if the programmer writes a piece of code, it should always be with the intention of actually running it in <em>some</em> scenario. But the C# compiler for example seems to disagree with this and merely reports a warning.</p>
  
  <p>Note: I realize good dead code detection is a very difficult problem, but that is not the focus of this question.</p>
  
  <p>Here are some examples of pieces of code where some statements are clearly unreachable:</p>
  
  <pre><code>return;
  foo();
  </code></pre>
  
  <p>--</p>
  
  <pre><code>throw new Exception();
  foo();
  </code></pre>
  
  <p>--</p>
  
  <pre><code>if (...) {
    return;
  } else {
    throw new Exception();
  }
  foo();
  </code></pre>