How does returning values from a function work?

后端 未结 8 1686
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 12:16

I recently had a serious bug, where I forgot to return a value in a function. The problem was that even though nothing was returned it worked fine under Linux/Windows and on

8条回答
  •  感动是毒
    2021-01-05 12:32

    When popping values from the stack in IBM PC architecture there is no physical destruction of the old values ​​of data stored there. They just become unavailable through the operation of the stack, but still remain in the same memory cell.

    Of course, the previous values ​​of these data will be destroyed during the subsequent pushing of new data on the stack.

    So probably you are just lucky enough, and nothing is added to stack during your function's call and return surrounding code.

提交回复
热议问题