Bug in cc(1), doesn't catch syntax error

Peter Wolfe wolfe at winston.UUCP
Fri Dec 6 05:16:29 AEST 1985


Description:
    
    cc(1) will generate incorrect code if you declare a forward reference
    and inadvertantly have an argument inside the ().  No complaints
    or warnings just wrong code.

    Lint does not really catch it etiher.

Repeat-By:

    extern int pw(ptr); <<<<<<<<---------------- admittly illegal

    int pw(d, l)
    char *d;
    short l;
    {
	pw(d, l);
    }

    Produces:

    LL0:
	    .data
	    .text
	    .align	1
	    .globl	_pw
    _pw:
	    .word	L12
	    jbr 	L14
    L15:
	    cvtwl	12(ap),-(sp)	<<<<<<<--------------- should be 8
	    pushl	8(ap)		<<<<<<<--------------- should be 4
	    calls	$2,_pw
	    ret
	    .set	L12,0x0
    L14:
	    jbr 	L15
	    .data

    Lint (lint test.c) says the following:

    test.c:
    test.c(6): warning: argument ptr unused in function pw
    pw: variable # of args.	test.c(6)  ::  test.c(7)
    pw, arg. 1 used inconsistently	test.c(6)  ::  test.c(7)
    pw, arg. 2 used inconsistently	test.c(6)  ::  test.c(7)

Fix:
    
    Here I am out of my depth.  Probably this will all be fixed when
    pcc gets its ANSI standard upgrade?
-- 

    Peter Wolfe
    New Media Technologies
    ..decvax!microsoft!ubc-vision!winston!wolfe
    ..ihnp4!alberta!ubc-vision!winston!wolfe



More information about the Comp.bugs.4bsd.ucb-fixes mailing list