🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3244

Re: Must main return a value?

#3244
From: Norman Diamond
Date: Fri, 28 Jun 1991 05:58
19 lines
1694 bytes
In article <7830001@hpwrce.HP.COM> walterm@hpwrce.HP.COM (Walter Murray) writes:
>Is the following program strictly conforming?
>   int main(void) { return; }
>Many people have written that the main function must return a value.
>I can't find such a requirement in the Standard.  I have read 2.1.2.2.3
>and 3.6.6.4.  Am I missing something?

For the effect of the program to be defined, the main function must return
a value.  It does seem strange that the compiler is required to issue a
diagnostic for a return statement with a value in a void function, but not
for the opposite mistake.

OK, if you don't want your program to send a small nuclear device at your car,
the main function must return a value.  (2.1.2.2 neither allows nor disallows
this extreme an effect; 3.6.6.4 allows it.)
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
Technical Details
Message-ID: <1991Jun28.055840.29919@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ubc-cs!van-bc!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!deccrl!news.crl.dec.com!nntpd.lkg.dec.com!tkou02.enet.dec.com!jit533!diamond
References: <7830001@hpwrce.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ubc-cs!van-bc!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!deccrl!news.crl.dec.com!nntpd.lkg.dec.com!tkou02.enet.dec.com!jit533!diamond
From: diamond@jit533.swstokyo.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Must main return a value?
Message-ID: <1991Jun28.055840.29919@tkou02.enet.dec.com>
Date: 28 Jun 91 05:58:40 GMT
References: <7830001@hpwrce.HP.COM>
Sender: usenet@tkou02.enet.dec.com (USENET News System)
Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 19