Hi all,

  Simple testcase, using h...@155680.

------------------------------------------------------------------------
$ cat badwarn.cpp

extern void bar (void);
int foo (void) __attribute__ ((__noreturn__));

int
foo (void)
{
  while (1)
  {
    bar ();
  }
}

$ g++-4 -c badwarn.cpp  -Wall
badwarn.cpp: In function 'int foo()':
badwarn.cpp:12:1: warning: no return statement in function returning non-void
------------------------------------------------------------------------

  The noreturn attribute doesn't make any difference; it still complains even
without it.  However compiling the example as C (either by renaming the
extension or using "-x -c") makes the warning go away.

  I would expect GCC to realise that the loop never exits and not worry about
the missing return value.  In C++ of course there are exceptional exits from
that loop even when the loop condition is known to be always true.  Does this
mean that the return statement is needed even if it's only ever going to be
skipped straight over during throwing an exception or longjmp()ing?  If this
isn't intentional, I'll file a PR.


    cheers,
      DaveK

Reply via email to