Why “not all control paths return a value” is warning and not an error?

后端 未结 7 1809
花落未央
花落未央 2020-12-02 01:48

I was trying to answer this question. As suggested by the accepted answer, the problem with that code is that not all control paths are returning a value. I tried this code

7条回答
  •  Happy的楠姐
    2020-12-02 02:06

    It is not an error because it may be the intended behaviour. For example, some encryption libraries use uninitialized local data as a step for seeding. As return values are kept in calling-convention and platform specific locations, this may help in some unusual (like the above) situations. In this case, the function returns whatever is left on the register used to return the return value.

提交回复
热议问题