Reaching end of function without return statement

后端 未结 2 1871
庸人自扰
庸人自扰 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 06:45

    In both C99 TC2 and C11 it is 6.9.1/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.

    In C++11 and C++14 it is [stmt.return]/2:

    Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function

提交回复
热议问题