GCC thinks that an infinite loop terminates?

77 Views Asked by At

Why is the commented line below required when compiling with -Wall?

static int H()
{
  while (1);
  __builtin_unreachable(); // Why do I need this line?
}

int main()
{
  H();
}

Without the __builtin_unreachable(), gcc 5.4.0 on linux x86 produces the following warning:

warning: no return statement in function returning non-void [-Wreturn-type]

Why does gcc not realize that the infinite loop in H() does not terminate?

0

There are 0 best solutions below