Re:The tiniest C sort function?
by tedunangst on Tuesday January 12, 2010 @02:49PM
(#1048325)
Implicitly returning int is not the same as implicitly returning 0. If it falls off the bottom, the return value is undefined. No additional machine code.
Ah, I guess it's just main that implicitly returns 0.
If memory serves correctly, I believe the typical calling convention for x86 is returning ints in %eax. So the caller will interpret whatever happens to be in %eax at the time as the return value.
If memory serves, that means the method now implicitly returns int and has an implicit "return 0;" at the end. Sure the source code is smaller, but the actual machine code is larger. Going for the shortest source code is pretty silly, but then this isn't exactly a serious endeavor :)