It should not work and certainly do not work on all compilers and target OS, even if it works on yours.
The likely explanation is that a function returning int always return something, and it's usually the content of a register. It probably happens that the register used for return value is in your case the same used to compute the last expression before returning from the function (on x86 targets, certainly eax).
This being said, an optimizing compiler detecting that there is no return is allowed to completely remove the code of this function. Henceforth the effect you see (may) disappear when activating higher optimizations levels.
I tested it with gcc:
gcc without optimization: inputs 10, 20 -> result is 10
gcc -O1 inputs 10, 20 -> result is 1
gcc -O2 inputs 10, 20 -> result is 0