2
void sbs(){
      exit(0);
    }

warning:

function might be possible candidate for attribute ‘noreturn’

Getting a warning as no return.. But here the return is not called, instead exit(0) is called.

Natan Streppel
  • 5,759
  • 6
  • 35
  • 43
Angus
  • 12,133
  • 29
  • 96
  • 151

2 Answers2

4

The warning is completely legit.

Attribute noreturn means you should write your prototype like this:

C11: _Noreturn void neverreturn()

_Noreturn is the attribute.

or the GCC variant: __attribute__((__noreturn__)) void neverreturn()

Here its obviously __noreturn__.

With this the compiler can make optimizations because it knows the function never will return.

Marco
  • 7,007
  • 2
  • 19
  • 49
-1

As mentioned by others ,your function should give the indication to compiler that it will not return to the caller.

Please check the bellow links.

What is the point of noreturn?

‘noreturn’ function does return

Community
  • 1
  • 1
pradipta
  • 1,718
  • 2
  • 13
  • 24