From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Fri, 23 Apr 2010 19:53:24 BST." <239c41a785c8c5638338c2f007f50733@vitanuova.com> References: <239c41a785c8c5638338c2f007f50733@vitanuova.com> From: Bakul Shah Date: Fri, 23 Apr 2010 13:08:14 -0700 Message-Id: <20100423200815.03B385B4A@mail.bitblocks.com> Subject: Re: [9fans] BUG!!! in Plan9 compiler! Topicbox-Message-UUID: 0cd3155e-ead6-11e9-9d60-3106f5b1d025 On Fri, 23 Apr 2010 19:53:24 BST C H Forsyth wrote: > >As per C89 in this case the unsigned char value should be > >promoted to a *signed* int value. The sum will be of type > >signed int and so the division will do the right thing. In > >kencc case it seems the sum has type unsigned int for some > >reason and further, the signed divisor (2) is promoted to an > >unsigned int. Seems like a bug. > > on 19 April, I wrote: > >notably the compiler doesn't implement the value-preserving rules for compar > isons. ... > >instead the compiler implements the older unsigned-preserving rule Does the following assertion fail under plan9? int x = 1234, y = -4321; unsigned char z = 12; int r1, r2; r1 = (x + y + z)/2; x += z; r2 = (x + y)/2; assert(r1 == r2); If so, I consider it a bug; particularly as there is no overflow involved anywhere.