Article View: gnu.gcc.bug
Article #487VMS 5.1/GCC 1.35 return value bug (cont.)
From: BAIHELP%TAMSTAR.BITNET
Date: Thu, 20 Jul 1989 17:26
Date: Thu, 20 Jul 1989 17:26
43 lines
2745 bytes
2745 bytes
In reference to the problem of VMS 5.1 needing a longword 1 in r0 if
no other value is supplied:
o Unix lets you drop out of the bottom of main.
o Microsoft C lets you drop out of the bottom of main.
o From "The C Programming Language" by K&R pg. 26
A function need not return a value; a RETURN statement
with no expression causes control, but no useful value,
to be returned to the caller, as does "falling off the
end" of a function by reaching the terminating right
brace. And the calling function can ignore a value
returned by a function.
... Since MAIN is a function like any other, it may
return a value to its caller, which is in effect the
environment in which the program was executed.
... we have omitted RETURN statements from our MAIN
functions up to this point, but we will include them
hereafter, as a reminder that PROGRAMS SHOULD RETURN
STATUS TO THEIR ENVIRONMENT.
Hence, since I won't get into an arguement about "good programming
style", I will say that the problem lies not with the VAX C compiler
but with the operating system. VMS expects a status return value in
general purpose register 0 and if not supplied retruns an error the
the process running the program. Now if "in the interests of good
style" a programmer would use exit(n); to halt his program on error,
then sould we not assume that if a program is about to drop off the
end of main and hasn't set a prefered return value that one may be
assumed for it. This allows COMPATIBILITY with the VMS 5.1 operating
system.
I am not suggesting this change be made for all implementations of
GCC, only for those running under VMS which need it.
Bryan A. Ignatow
VMS Software Specialist
Public Domain Software Specialist
Academic Vax Systems
Texas A&M University
Bitnet: BAIHELP@TAMVENUS
Internet: BAIHELP@venus.tamu.edu
Technical Details
Message-ID:
<8907201728.AA19125@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MITVMA.MIT.EDU!BAIHELP%TAMSTAR.BITNETShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MITVMA.MIT.EDU!BAIHELP%TAMSTAR.BITNET From: BAIHELP%TAMSTAR.BITNET@MITVMA.MIT.EDU Newsgroups: gnu.gcc.bug Subject: VMS 5.1/GCC 1.35 return value bug (cont.) Message-ID: <8907201728.AA19125@life.ai.mit.edu> Date: 20 Jul 89 17:26:00 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 43