From a technical point of view, you invoke "undefined behavior". Undefined behavior behaves, well, without definition. If the behavior of your program is undefined, it can print 512, 4, 99, or even the full text of the Gettysburg address.
I would not describe the results that you showed as "working" in the reasonable sense of the word.
Ps If you use the GNU compiler collection, I recommend using at least these switches: "-Wall -Werror".
Pps Over the years, a few days before the ANSI C standard, some non-optimizing Z-80 C compiler would accept this piece of code:
int ReturnThree() { 3; }
and enter the same code as the user:
int ReturnThree() { return 3; }
Robᵩ
source share