🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #898

Re: GCC 1.36 long long bug: ``if (x--)'' not compiled correctly

#898
From: Ron Guilmette
Date: Sat, 20 Jan 1990 04:41
28 lines
1361 bytes
In article <9001160507.AA01142@burns.twinsun.com> eggert@burns.twinsun.com (Paul Eggert) writes:
>The following program should yield exit status 0.
>When compiled under GCC 1.36, it yields 1.
>
>	long long x;
>	main()
>	{
>		if (x--)
>			return 255;
>		return 0;
>	}
>
>SPARCstation 1 + SunOS 4.0.3c
>Same results on Sun-3 + SunOS 4.0.3

This is probably *not* the fault of the compiler.  You are using Sun's
crt0 file which (I assume) doesn't use the value returned from main() to
properly set the exit status (upon exit).

I have been told that when there exists a real honest-to-god GNU libc.a,
then this problem will go away because we can all start to use a more
correct (GNU) version of crt0.

P.S.  Since g++ already comes with its own crt0 file (it has to) the
above program, if compiled with g++, will (I believe) correctly exit
with a zero status.

// rfg
Technical Details
Message-ID: <25B7EBE2.23511@paris.ics.uci.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!jarthur!uci-ics!rfg
References: <9001160507.AA01142@burns.twinsun.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!jarthur!uci-ics!rfg
From: rfg@ics.uci.edu (Ron Guilmette)
Newsgroups: gnu.gcc.bug
Subject: Re: GCC 1.36 long long bug: ``if (x--)'' not compiled correctly
Message-ID: <25B7EBE2.23511@paris.ics.uci.edu>
Date: 20 Jan 90 04:41:06 GMT
References: <9001160507.AA01142@burns.twinsun.com>
Reply-To: rfg@ics.uci.edu (Ron Guilmette)
Distribution: gnu
Organization: UC Irvine Department of ICS
Lines: 28