[gnu.gcc.bug] bug in SUN-3 gcc-1.28 when *not* optimising.

paul@UUNET.UU.NET (Paul Hudson) (10/05/88)

The following program prints mostly nulls when compiled with "gcc -o
crap crap.c". It looks like it's printing correctly only the character
returned by the occasional call to _filbuf in getc.

Optimise the program and it works.

This bug I believe has other manifestations in other programs of
mine. Unfortunately, they're much too big to post.

Ember? it's not really a flame; is gcc going to get more stable? I
know it costs me nothing, and it's an excellent compiler (which is why
I'm saying this), but it's difficult to know which version I should be
using for products for distribution. I would like to have programs I
distribute contain as far as possible only the bugs I put there! Is
there a case for a secondary release of each version (1.28b?) which
just bug-fixes rather than improves? 

#include <stdio.h>
main()
{
    FILE *fred = fopen("/etc/termcap", "r");
    while(1)
    {
	int c;
	c = getc(fred);
	putchar(c);
    }
}

Paul Hudson 

Snail mail: Monotype ADG	Email:	...!ukc!acorn!moncam!paul
	    Science Park,		paul@moncam.co.uk
	    Milton Road,	"Sun Microsysytems:
	    Cambridge,		 The Company is Arrogant (TM)"
	    CB4 4FQ