Original Post
🔒 Locked
implicit return values?
Advertisement
I'd wager it is compiler specific. I don't know for sure though, as it's easy enough to make sure the function returns something.
[edit: while I cannot find anything definative quickly, the side-comments I did find imply that it is compiler specific, and will tend towards returning garbage]
[edit: while I cannot find anything definative quickly, the side-comments I did find imply that it is compiler specific, and will tend towards returning garbage]
The return value on x86's is placed in the eax register not on the stack. However, you are right that you will just get random data. Perhaps eax is empty, perhaps there's something in it. Unless you write the assembly yourself, you have no idea what the compiler has used for registers.
Could very well be different on Macs... And I'm pretty positive it's different on mainframes.
But one should never rely on quirks of a compiler. If you method/function is defined to return a value. For heavens sake just return a value. Espeacial if you are going to check it later, else why would you define the function to have a return value.
But one should never rely on quirks of a compiler. If you method/function is defined to return a value. For heavens sake just return a value. Espeacial if you are going to check it later, else why would you define the function to have a return value.
The behavior is undefined. That means that it is not necessarily architecture-specific or compiler-specific. It could return 0. It could return 37. It could cause your computer to burst into flames and order a pizza. It could do something different each time you compile it, or each time you run it. Don't count on the behavior under any circumstances.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement