8th Nov 2017, 7:47 PM
SANGMESH PATIL
SANGMESH PATIL - avatar
4 Answers
+ 13
in the link @Sapphire supplied: https://stackoverflow.com/questions/32513793/c-and-c-functions-without-a-return-statement especially this possible explanation: "Odds are what's going on here is that the result of the last expression is getting stored in the same register (on an x86, EAX or RAX) that the compiler is using for the return value of the function. When the function returns, the return instruction leaves this register alone, and the calling code simply assumes the value there is the return value of the function." above it all, this is called "undefined behaviour", where you would not know what to expect
8th Nov 2017, 8:10 PM
Burey
Burey - avatar
8th Nov 2017, 8:09 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Because 10 + 20 is 30. But I know what you're referring to with the non-returning function. Technically it's a violation, at least should provide a warning. But simply put, the compiler is unable to tell. There's a similar question to yours with a better explanation on Stackoverflow: https://stackoverflow.com/questions/32513793/c-and-c-functions-without-a-return-statement
8th Nov 2017, 8:07 PM
Sapphire