lint bug: f((int) double expr)

Dave Decot decot at cwruecmp.UUCP
Sun Mar 11 18:31:01 AEST 1984


Description:
    Lint (actually, probably pcc) incorrectly decides that the type of many
    double expressions cast to int and used as parameters is still double.

Repeat-by:
    running lint(1) with no flags on the following:

	main() {
	    foo((int) 1.0);
	}

	foo(x)
	int x;
	{
	     printf("%d\n", x);
	}
    
    yields

	foo, arg. 1 used inconsistently	tst.c(7)  ::  tst.c(2)

Fix:
    % cd /usr/src
    Permission denied.

Hints:
    Double expressions cast to int are allowed to be added to pointers.

    Changing the type of the formal parameter to double suppresses
    the message, as does replacing the 1.0 with a declared and initialized
    float or double variable.

Dave Decot	 decvax!cwruecmp!decot



More information about the Comp.lang.c mailing list