232
unsafeCode
(lemmy.ml)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Not needed, main in C++ implicitly returns 0 if there is no return
Should ≠ Needs to
You can do it, and it will work, but it's unclean and not best-practice. I wouldn't be surprised if it's undefined behaviour.
Just to clarify. It is defined behavior - there's plenty of undefined behavior in C but that ain't one of them.
Interesting feature, I had no idea. I just verified this with gcc and indeed the return register is always set to 0 before returning unless otherwise specified.
spoiler
produces:
produces: