4.1 C compiler bug (a new one, maybe)

utzoo!decvax!harpo!seismo!hao!hplabs!luigi utzoo!decvax!harpo!seismo!hao!hplabs!luigi
Mon Feb 28 15:58:25 AEST 1983


I just found another 4.1bsd C compiler bug, probably related to the ones
that have been mentioned about arguments to a procedure that appear from
nowhere. This one is not that glamorous, but equally subtle. Look at the
procedure foo (filthy): the argument type declaration does not realize
that guilty is not in the argument list. Strange things then clearly happen.

    /*******************/

    int guilty;	/* this declaration is necessary for the error to turn up */
    int parm;


    main(){
	foo(parm);
    }

    foo (filthy)
    short guilty;	/* this is not detected */
    {
	/* these work, but filthy is assumed to be of type int */
	filthy = 3;
	parm = filthy;

	/* these do not work; however you get a warning message */
	guilty = 3;
	parm = guilty;
    }


By the way, I found this bug accidentally in the "ld" source.
It changes a long into an int, so it has no effect on the VAX.
I wonder about other machines.

Luigi Semenzato - HP Labs



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