Topic: int main() can you show me the part of the standard for c++ that


Author: James Dennett <jdennett@acm.org>
Date: Sun, 3 Jun 2001 20:11:03 GMT
Raw View
John Harrison wrote:
>
> "Pieter Pareit" <pieter.pareit@planetinternet.be> wrote in message
> news:9fbd67$n2v$1@news.planetinternet.be...
> > Can you show me the part of the standard for c++ that says I don't have to
> > return a value from main?
> >
> > tnx;
> >
>
> Section 3.6.1.5 - 'If control reaches the end of main without encountering a
> return statement, the effect is that of executing return 0;'
>
> But why? That's what I want to know.

It does have the desirable effect of removing one commonly
invoked piece of undefined behaviour from the Standard; it
has been very common for sloppy users to fail to return a
value from main.  (It has the undesirable effect of
introducing an inconsistency, in that main is the only
function to which this applies.)

I don't know if that was the reason for the change though,
as I was not part of the Standardisation process when the
rule was written.

Can anybody on comp.std.c++ cast any light on this?

-- James Dennett

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]