Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!utah-cs!donn From: donn@utah-cs.UUCP (Donn Seeley) Newsgroups: comp.bugs.4bsd Subject: more problems with the VAX PCC and unsigned constants Message-ID: <4012@utah-cs.UUCP> Date: Thu, 13-Nov-86 01:45:33 EST Article-I.D.: utah-cs.4012 Posted: Thu Nov 13 01:45:33 1986 Date-Received: Thu, 13-Nov-86 05:28:09 EST References: <213@cartan.Berkeley.EDU> <3994@utah-cs.UUCP> Organization: University of Utah CS Dept Lines: 58 This was pointed out by Spencer Thomas when he was testing Kenneth Ballou's bug report on constant conversions from unsigned types to floating types... The compiler performs all unsigned constant comparisons as signed. For example the following program incorrectly prints '0': main() { printf("%d\n", (unsigned) 0xffffffff > 0); exit(0); } The fix is in conval() in lib/mip/trees.c: ------------------------------------------------------------------------ *** /tmp/,RCSt1029210 Wed Nov 12 23:27:09 1986 --- trees.c Mon Nov 10 09:22:34 1986 *************** *** 739,754 **** p->tn.lval = p->tn.lval >= val; break; case ULT: ! p->tn.lval = (p->tn.lval-val)<0; break; case ULE: ! p->tn.lval = (p->tn.lval-val)<=0; break; - case UGE: - p->tn.lval = (p->tn.lval-val)>=0; - break; case UGT: ! p->tn.lval = (p->tn.lval-val)>0; break; case EQ: p->tn.lval = p->tn.lval == val; --- 739,754 ---- p->tn.lval = p->tn.lval >= val; break; case ULT: ! p->tn.lval = p->tn.lval < (unsigned) val; break; case ULE: ! p->tn.lval = p->tn.lval <= (unsigned) val; break; case UGT: ! p->tn.lval = p->tn.lval > (unsigned) val; ! break; ! case UGE: ! p->tn.lval = p->tn.lval >= (unsigned) val; break; case EQ: p->tn.lval = p->tn.lval == val; ------------------------------------------------------------------------ Don't ask me why anyone might have thought the old code would work, Donn Seeley University of Utah CS Dept donn@utah-cs.arpa 40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn