Reaching end of function without return statement

后端 未结 2 1867
庸人自扰
庸人自扰 2021-01-06 06:05

ANSI X3.159-1989, section 3.6.6.4, lines 33-35 state:

“If a return statement without an expression is executed, and the value of the function call

2条回答
  •  有刺的猬
    2021-01-06 07:01

    As to the first sentence (your source appears to be wrong or outdated):

    C 2011 6.8.6.4 The return statement

    1 A return statement with an expression shall not appear in a function whose return type is void. A return statement without an expression shall only appear in a function whose return type is void.

    As to the second sentence:

    C 2011 6.9.1 Function definitions

    12 If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.

提交回复
热议问题