A bug in the 2.8BSD C compiler

scw%ucla-locus at cepu.UUCP scw%ucla-locus at cepu.UUCP
Sat Sep 17 07:54:00 AEST 1983


From:  Steve Woods <cepu!scw at ucla-locus>

There is a bug in the Berkley C compiler (in c1) as follows:

    The problem was first noticed during a fortran compile. The symptom
was an error from the asm pass (x 0034).  The statment being compiled into
the error is the goto part of an assigned goto.  The cause of the error
is a bad template for the Ritchie code generator.  The cause of the bad
template is the Sccs id comment in table.s. Table.s is processed by
a program called cvopt before being given to as. The bug will affect all
indirect jump commands generated by the c compiler.


The FIX, remove the sccs comment from table.s.

this is the line -> /*	@(#)table.s	2.1	SCCS id keyword	*/
		    /
		    / c code tables-- compile to register
		    /

A fortran program to use when checking for the problem:

	integer i
	assign 20 to i
	goto i,(20,30)
20	continue
30	continue
	stop
	end

The output (with much crud removed) of f77 -S test.s. Note the difference
on line 5.

	correct text		incorrect text

     1	.text			    .text
     2	jbr	L11		    jbr	    L11
     3	L12:mov $L14,2+v.1	    L12:mov $L14,2+v.1
     4	clr	v.1		    clr	    v.1
     5	jmp	*2+v.1		    jmp	    *2+v.1L14:L15:clr	    -(sp)
     6	L14:L15:clr	-(sp)	    sxt	    -(sp)
     7	sxt	-(sp)		    mov	    $L16,-(sp)
     8	mov	$L16,-(sp)	    jsr	    pc,_s_stop
     9	jsr	pc,_s_stop	    add	    $6,sp
    10	add	$6,sp		    L13:jmp cret
    11	L13:jmp cret



More information about the Comp.unix.wizards mailing list