Why is 0 moved to stack when using return value?

前端 未结 4 1294
逝去的感伤
逝去的感伤 2020-12-18 06:44

I\'m experimenting disassembling clang binaries of simple C programs (compiled with -O0), and I\'m confused about a certain instruction that gets g

4条回答
  •  太阳男子
    2020-12-18 07:35

    According the the standard (for hosted environments), 5.1.2.2.1, main is required to returrn an int result. So do not expect defined behavior if violating this.

    Furthermore, main is actually _not required to explicitly return 0; this is implicitly returned if it reaches the end of the function. (Note this is only for main, which also does not have a prototype.

提交回复
热议问题