SUN C compiler bug?

VLD/VMB gwyn at BRL.ARPA
Sat Mar 29 15:28:52 AEST 1986


When dissimilar types occur in an expression, they are converted
into comparable types according to rules you can find in K&R,
better in Harbison&Steele, better still in the X3J11 draft.  The
conversion involves widening smaller types, not shrinking fatter
ones.  Since 128 is an (int), the (char) x should have been
widened to (int) before the < comparison.  On the other hand,
you have the problem that signed chars will never widen to
something >= 128 (assuming 8-bit byte), so the loop would never
terminate.  Yes it's a bug, but the code is buggy too.



More information about the Comp.lang.c mailing list