Incorrect warning

Ian Lance Taylor ian@zembu.com
Thu Jun 24 13:51:00 GMT 1999


I get an incorrect warning when I compile this C++ code with the
current CVS sources:

#include <cstdlib>

class c1
{
public:
  virtual void f1 () __attribute__ ((__noreturn__));
  void f2 () __attribute__ ((__noreturn__));
};

void
c1::f1 ()
{
  exit (0);
}

void
c1::f2 ()
{
  f1 ();
}

I get this:

/home/ian/foo1.cc: In method `void c1::f2()':
/home/ian/foo1.cc:20: warning: `noreturn' function `c1::f2()' does return

f2 calls f1, and f1 is marked to not return, so I believe f2 should be
presumed to not return.

If I change the method f1 to be non-virtual, then I do not get this
warning.

Note that I get this warning even if I do not specify any -W options.

Ian


More information about the Gcc-bugs mailing list