[PATCH] NoReturn Warning: Non-Void Return Type

Michael Bao mike.h.bao at gmail.com
Sun Jan 5 17:17:52 PST 2014

On Sun, Jan 5, 2014 at 7:30 PM, David Blaikie <dblaikie at gmail.com> wrote:
>   Is this an existing warning in another compiler?

The only other compiler I have access to right now is GCC 4.8 and from
what I can tell they do not have this warning. However, their docs say
that it does not make sense for a noreturn function to have a return
type other than void

>   Is it finding bugs?

I can't say for sure if this particular would find bugs or not, but I
think marking a noreturn function as having a return type could
potentially be confusing?.

>   How does this interact with virtual functions? (what if I'm overriding a
>   non-void non-noreturn function with a noreturn function?)

If I understand your question correctly...I quickly made up this example:
class TestClass {
  virtual int cfoo() {
    return 0;

class TestClass2: public TestClass {
  __attribute__((noreturn)) virtual int cfoo() {
    return 1;

The warning is emitted on the cfoo() function in TestClass2 as expected.


More information about the cfe-commits mailing list