Article View: comp.std.c
Article #3251Re: Must main return a value?
From: Lawrence H. Miller
Date: Sat, 29 Jun 1991 00:24
Date: Sat, 29 Jun 1991 00:24
26 lines
1549 bytes
1549 bytes
In article <16575@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <7830001@hpwrce.HP.COM> walterm@hpwrce.HP.COM (Walter Murray) writes: >>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? > >You must be -- 2.1.2.2.3 states explicitly "If the main function executes a >return that specifies no value, the termination status returned to the host >environment is undefined." That meets the condition for causing undefined >behavior on at least two counts. The question one might ask of a standards body is why this is "undefined" and not "implementation defined," since it clearly involves the program's interaction with its host. This is, in fact, alluded to in the description of the exit() function in 4.10.4.3: If the value [returned] is EXIT_SUCCESS... If the value [returned] is EXIT_FAILURE... Otherwise the status returned is implementation-defined. -- Larry Miller The Aerospace Corporation lmiller@aero.org (213 soon to be 310)336-5597
Technical Details
Message-ID:
<1991Jun29.002410.27632@aero.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!aero-c!lmillerReferences:
<7830001@hpwrce.HP.COM> <16575@smoke.brl.mil>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!aero-c!lmiller From: lmiller@aero.org (Lawrence H. Miller) Newsgroups: comp.std.c Subject: Re: Must main return a value? Message-ID: <1991Jun29.002410.27632@aero.org> Date: 29 Jun 91 00:24:10 GMT References: <7830001@hpwrce.HP.COM> <16575@smoke.brl.mil> Sender: news@aero.org Organization: The Aerospace Corporation, El Segundo, CA Lines: 26