4 ms·
On Linux/Unix you will get in a (somewhat) random exit value, so if you run the program from a "set -e" script it will randomly fail. I guess that didn't bother
by nn3 4y ago
On Linux/Unix you will get in a (somewhat) random exit value, so if you run the program from a "set -e" script it will randomly fail. I guess that didn't bother whoever "allowed" that, but I consider it a bug.
- matthews2 4y agoThere's an implicit return zero in C++.
- pjmlp 4y agoIn C yes, on C++ it is required to return 0 if omited.
- garaetjjte 4y agoC99 also defines it: >5.1.2.2.3 Program termination [...] reaching the } that terminates the main function returns a value of 0.
- pjmlp 4y agoThanks for the heads up, than it sums it up either the OP was using a broken implementation, or the incorrect language version.
- Jtsummers 4y agoIt shouldn't in C++. Omitting an explicit return (or falling through to the end without hitting another return) should have the same result as if you ended it with `return 0`. If it's returning a random value then that is erroneous behavior. I've also never witnessed this and print non-zero exit codes in my command line prompt (so after execution my prompt looks like `blahblah(EXIT_CODE) $`). And I just looked it up for C. Since C99, if the return type of `main` is `int` and there is no explicit return (or again you fall through to the end without hitting one) there's an implicit `return 0`. Before C99, undefined.