[net.unix-wizards] System III Ritchie C compiler bug

gwyn@utexas-11@sri-unix (05/28/82)

From: Douglas A Gwyn <gwyn@utexas-11>
Date:  2 May 1982 at 2315-CDT
The new C optimizer allocates string storage off the stack for the first
5000 characters, then overflows to the heap as before.  Unfortunately,
the allocator can wrap around the address space (this happened three
times during compilation of the compiler, for example).  In module c21.c,
change line 386 from
	if (alasta+n < alastr) {
to
	if (alasta+n < alastr && alasta+n > alasta) {
in order to catch the wrap-around.  Note also that line 182 of c21.c
		r = -1;
is superfluous.

While fixing the bug, you might want to install the following change in
module c11.c starting at line 862, in order to permit auto floats to
work correctly (since otherwise access causing stack growth will abort
a floating-point operation -- an FP11/KT11 design botch):
		switch ( t = geti() - 6 )
			{
		case 4:			/* NOT "cmp -(sp),-(sp)" */
			printf( "tst	-(sp)\n" );
		case 2:
			printf( "tst	-(sp)\n" );
		case 0:
			break;
		default:
			printf( "sub	$%o,sp\n", t );
			/* pre-extend stack to avoid KT11 problem */
			printf( "tst	(sp)\n" );
			}
		break;
This fix may not be necessary on all PDP-11s but is needed for an 11/34.
-------

geoff (05/31/82)

I believe that there is a newsgroup for USG 3 bugs, net.bugs.u3.
Now that USG 3 (a.k.a. System III) bug reports are starting to come in,
could people please use net.bugs.u3, or more generally net.bugs,
instead of net.unix-wizards.

Geoff Collyer, U. of Toronto Computing Services