Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site elsie.UUCP
Path: utzoo!linus!decvax!harpo!seismo!rlgvax!cvl!elsie!ado
From: ado@elsie.UUCP
Newsgroups: net.bugs.4bsd
Subject: C compiler bug (better fix)
Message-ID: <812@elsie.UUCP>
Date: Sat, 11-Feb-84 19:23:10 EST
Article-I.D.: elsie.812
Posted: Sat Feb 11 19:23:10 1984
Date-Received: Wed, 15-Feb-84 06:09:40 EST
Organization: NIH-LCM, Bethesda, MD
Lines: 45

Subject: 4.?bsd C compiler error (better fix)
Index:	.../pcc/local2.c in 4.?BSD

Description:
	The C compiler generates incorrect code in some cases.
	A fix posted earlier fixed the problem while degrading code in some
	cases; this fix avoids code degradation.
Repeat-By:
	Use the command
		cc -S test.c
	where test.c contains:
		test()
		{
			register struct {
				short	i;
				short	j;
			} * sp;
			while ((sp++)->i != 0);
		}
	and then look at the "test.s" file produced.  You'll see that the
	"while" loop generates this code:
		 L16:
			tstw	(r11)+
			jeql	L17
			jbr 	L16
	which only increments r11 by two (rather than four) each time through.
Fix:	This is the fix to the version distributed by Berkeley.

	ed - .../pcc/local2.c
	/ISPTR(p->in.left->in.type)/c
	#ifdef OLDVERSION
					if ( ISPTR(p->in.left->in.type) ) {
	#else
	/*
	** We want to look for a pointer to a pointer, rather than a pointer.
	*/
					if ( ISPTR(p->in.left->in.type) &&
					   ISPTR(DECREF(p->in.left->in.type))) {
	#endif OLDVERSION
	.
	w
	q
-- 
UUCP:	decvax!harpo!seismo!rlgvax!cvl!elsie!ado
DDD:	(301) 496-5688