The ISO 1998 c++ standard specifies that not explicitly using a return statement in the main is equivalent to use return 0
.
But what if an implementation has a different standard "no error" code, for example -1
?
Why not use the standard macro EXIT_SUCCESS
that would be replaced either by 0
or -1
or any other value depending on the implementation?
C++ seems to force the semantic of the program, which is not the role of a language which should only describe how the program behaves. Moreover the situation is different for the "error" return value: only EXIT_FAILURE
is a standard "error" termination flag, with no explicit value, like "1" for example.
What are the reasons of these choices?