title: error: function declared 'noreturn' should not return
body: <p>At my workplace, we have a different internal name for <code>noreturn</code> attribute. Suppose it is <code>INTERNAL_DONT_RETURN</code></p>
  
  <p>I am writing a member function of a class where I do something like</p>
  
  <pre><code>INTERNAL_DONT_RETURN void foo() const
  {
      if(!*this)
      {
         throw CoolException();
      }
      m_call_throw();
  }
  </code></pre>
  
  <p>This m_call_throw() is a private class member <code>std::function&lt;void()&gt;m_call_throw</code>  which gets populated in the class's constructor as a lambda. This lambda does nothing but </p>
  
  <p><code>m_call_throw([uncoolID]() { throw UncoolException(uncoolID); })</code></p>
  
  <p>Now both, gcc-4.9.3 and clang gives me following warning </p>
  
  <p><code>error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
          }
          ^
  </code></p>
  
  <p>I have already consulted <a href="https://stackoverflow.com/questions/23452489/warning-noreturn-function-does-return">this</a> and <a href="https://stackoverflow.com/questions/15964219/noreturn-function-does-return">this</a> question but none of them explained the cause of above warning.</p>
  
  <p>1) Is compiler implicitly adding <code>return</code> as explained <a href="https://stackoverflow.com/a/23452545/1410711">here</a> ?</p>
  
  <p>2) Even when I am throwing exceptions why does compiler believe that my function will return?</p>
  
  <p>3) <a href="https://gcc.gnu.org/onlinedocs/gcc-4.3.2//gcc/Function-Attributes.html#index-g_t_0040code_007bnoreturn_007d-function-attribute-2160" rel="nofollow noreferrer">noreturn attribute</a> mentions that </p>
  
  <blockquote>
    <p>The noreturn keyword does not affect the exceptional path when that
    applies: a noreturn-marked function may still return to the caller by
    throwing an exception or calling longjmp.</p>
  </blockquote>
  
  <p>Is this relevant to my problem?</p>