[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Maybe one of out C standards people can define when the conversion
is defined to occur, so we can get a real ruling.
unsigned char i = 127;
printf("%d\n", (char)((i << 1) / 2));
...yields 127 on gcc 2.95, so it's definitely order of conversion
being totally screwed by gcc 3.1.
Basically, it's assuming commutability where it's not present.
> In any case, this behavior makes moused(8) return a stupid value of
> 127 when you roll the mouse wheel up under ps/2-sysmouse-intellimouse
> protocol. Attached is a patch that makes the whole expression look
> more logical and works around the above behavior at the same time.
[ ... ]
> - act->dz = ((char)(pBuf << 1) + (char)(pBuf << 1))/2;
> + act->dz = ((char)(pBuf << 1) + (char)(pBuf << 1)) >> 1;
This is *soooooooooo* counter intuitive that it's evil!
To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
with "unsubscribe freebsd-current" in the body of the message