www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - return statement bug 2

reply Nick <Nick_member pathlink.com> writes:
A main() returning a void does not give the OS return value 0. Case in point:

tst.d:
void main() {}

$ dmd tst.d
(compiles)
$ tst
$ echo $?
3
$

I would expect 0 to be returned unless an error occured.

Nick
Aug 12 2004
parent reply "Walter" <newshound digitalmars.com> writes:
It's not really a bug. If you don't care about the exit status, you don't
have to supply one (though it will then be garbage).

"Nick" <Nick_member pathlink.com> wrote in message
news:cfg4j9$2cad$1 digitaldaemon.com...
 A main() returning a void does not give the OS return value 0. Case in
point:
 tst.d:
 void main() {}

 $ dmd tst.d
 (compiles)
 $ tst
 $ echo $?
 3
 $

 I would expect 0 to be returned unless an error occured.

 Nick
Aug 14 2004
parent Nick <Nick_member pathlink.com> writes:
In article <cflklr$2j0e$1 digitaldaemon.com>, Walter says...
It's not really a bug. If you don't care about the exit status, you don't
have to supply one (though it will then be garbage).
That's OK, then. I always thought the required return at end of main in C (or at least gcc) redundant, since I would return 0 in almost every case. Therefore I guess I thought the void was a replacement for the exact same behavior. But, as you say, if I actually need the return value for something I should supply it explicitly. Nick
Aug 14 2004