Compiler bug

Guy Harris guy at auspex.UUCP
Sat Dec 17 14:41:46 AEST 1988


>So 3 out of 4 get it wrong.

3 out of 4 are based on PCC (4.3BSD C compiler, 4.3BSD "lint", and, I
suspect, Xenix "lint").  That's the nice thing about portable
software, the bugs port too....

The compiler problem may be due to PCC's incredible sensitivity to tiny
perturbations in the order in which various operations are done on the
expression trees; if you change one \s-22little tiny thing\s0 you can
end up with expressions not being evaluated at compile time to the
maximum extent possible.

I think a fix for the "lint" problem was posted a long time ago; if you
consider it dumb that it complains about an expression being constant in
a context where only constant expressions are allowed, it'll clean this
problem up.  Part of the reason why "lint" checks for constants in a
conditional context may be to catch things like

	if (a & MASK == VALUE)

which are equivalent to

	if (0)

since MASK != VALUE; what was desired was

	if ((a & MASK) == VALUE)

The nasty part is that sometimes a "constant in conditional context" is
caused by an error, and other times it's deliberate and desired; as one
version of the "lint" manual page stated, "There are some things you
just *can't* get 'lint' to shut up about."



More information about the Comp.lang.c mailing list