I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O):
int main(void) { unsigned char i = 127; printf("%d\n", ((char)(i << 1)) / 2); return 0; } gcc 2.95.4 says it's -1, whereas gcc 3.1 says it's 127. On FreeBSD char should be signed, so I suspect it's a (optimization) bug of gcc 3.1 which should be fixed. Or we'll have to do a mass audit of the whole src tree to check and fix the similar expressions. 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. -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." Index: moused.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/moused/moused.c,v retrieving revision 1.55 diff -u -r1.55 moused.c --- moused.c 28 Apr 2002 11:59:30 -0000 1.55 +++ moused.c 15 May 2002 17:16:40 -0000 @@ -1972,7 +1972,7 @@ act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); if (rodent.level == 1) { - act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2; + act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1)) >> 1; act->button |= ((~pBuf[7] & MOUSE_SYS_EXTBUTTONS) << 3); } break; To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message