Starting with the C99 standard, the compiler is required to generate the equivalent of a return 0
or return EXIT_SUCCESS
if no return is supplied at the end of main
. There was also a corresponding and identical change to the C++ language standard around that same time. I am interested in the reasons for both and I guessed that it was unlikely they were entirely separate and unrelated changes.
My question is:
What was the documented rationale for this change?
An ideal answer would cite authoritative sources for both C and C++ which is why I have tagged the question with both languages.
Note that unlike the question What the reasons for/against returning 0 from main in ISO C++?, I'm not asking for advice on whether to write return 0
in my programs -- I'm asking why the language standards themselves were changed.
To help understand the purpose for the question, here is a bit more of the context:
- Understanding why a change was made is helpful in deciding how to use it.
- Rationale is frequently included within the standard itself. For example, the C90 standard includes many explanatory footnotes such as footnote 36 which starts, "The intent of this list..."
I've studied the standards searching for the answer myself before I asked here, but did not find the answer. I've been asked to help write coding standards for both languages for a group of programmers and I wanted to make sure I understand why this feature exists so that I may accurately explain its use to others.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…