Why does “noreturn” function return?

前端 未结 9 1606
执念已碎
执念已碎 2020-12-25 10:51

I read this question about noreturn attribute, which is used for functions that don\'t return to the caller.

Then I have made a program in C.

         


        
9条回答
  •  感动是毒
    2020-12-25 11:05

    According to this

    If the function declared _Noreturn returns, the behavior is undefined. A compiler diagnostic is recommended if this can be detected.

    It is the programmer's responsibility to make sure that this function never returns, e.g. exit(1) at the end of the function.

提交回复
热议问题