[gnu.gcc.bug] GCC 1.36 long long bug: ``if

eggert@burns.twinsun.com (Paul Eggert) (01/16/90)

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

rfg@ics.uci.edu (Ron Guilmette) (01/20/90)

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