title: Clang warning in dubious case: function 'foo' could be declared with attribute 'noreturn'?
body: <p>I have been playing around a bit with the [[noreturn]] attribute, which I'm trying to get a handle of and make use of (I understand <code>[[noreturn]]</code> is a <a href="http://en.cppreference.com/w/cpp/language/attributes" rel="nofollow">C++11 standard attribute</a> and <code>__attribute__((noreturn))</code> is a GCC/Clang extension). As part of this, I enabled the Clang warning -Wmissing-noreturn.</p>
  
  <pre><code>&gt; clang++ -v
  Ubuntu clang version 3.7.1-svn253742-1~exp1 (branches/release_37) (based on LLVM 3.7.1)
  Target: x86_64-pc-linux-gnu
  Thread model: posix
  </code></pre>
  
  <p>foo.cpp:</p>
  
  <pre><code>enum bar
  {
    A = 1,
    B,
    C
  };
  
  void foo()
  {
    switch (bar())
    {
      case A:
      case B:
      case C:
      default:
        break;
    }
  }
  
  int main()
  {
    foo();
    return 0;
  }
  </code></pre>
  
  <p>Then compile:</p>
  
  <pre><code>&gt; clang++ foo.cpp -o foo -Wmissing-noreturn -std=c++14
  foo.cpp:9:1: warning: function 'foo' could be declared with attribute 'noreturn'
        [-Wmissing-noreturn]
  {
  ^
  1 warning generated.
  </code></pre>
  
  <p><strong>It appears to me that it would return! What's going on here?</strong> Is this a compiler bug?</p>
  
  <p>If you remove the "= 1" from A, then it compiles fine without a warning.</p>
  
  <p>If I do make the foo() function <code>[[noreturn]] void foo()</code>, then it does crash with a segmentation fault.</p>