2 ms·
Correct. > If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.
by tedunangst 4y ago
Correct.
> If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.
- planede 4y agoInterestingly C++ makes this UB. > Otherwise, flowing off the end of a function other than main or a coroutine ([dcl.fct.def.coroutine]) results in undefined behavior. https://timsong-cpp.github.io/cppwp/n4868/stmt.return#2.sentence-9 https://timsong-cpp.github.io/cppwp/n4868/stmt.return#2.sent... edit: This also manifests in compiler optimizations, at least in gcc https://godbolt.org/z/GhxjdWqGb https://godbolt.org/z/GhxjdWqGb