9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bakul Shah <bakul+plan9@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] BUG!!! in Plan9 compiler!
Date: Fri, 23 Apr 2010 13:08:14 -0700	[thread overview]
Message-ID: <20100423200815.03B385B4A@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Fri, 23 Apr 2010 19:53:24 BST." <239c41a785c8c5638338c2f007f50733@vitanuova.com>

On Fri, 23 Apr 2010 19:53:24 BST C H Forsyth <forsyth@vitanuova.com>  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.



  parent reply	other threads:[~2010-04-23 20:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-22 15:29 tlaronde
2010-04-22 17:03 ` Bakul Shah
2010-04-22 17:36   ` tlaronde
2010-04-22 17:50     ` tlaronde
2010-04-22 19:08       ` geoff
2010-04-22 19:32         ` tlaronde
2010-04-22 20:07           ` Bakul Shah
2010-04-22 21:15             ` tlaronde
2010-04-22 21:26               ` tlaronde
2010-04-22 22:49               ` Bakul Shah
2010-04-23  7:42                 ` tlaronde
2010-04-23 18:53                 ` C H Forsyth
2010-04-23 18:51                   ` tlaronde
2010-04-23 20:08                   ` Bakul Shah [this message]
2010-04-23 20:46                     ` ron minnich
2010-04-23 21:44                       ` erik quanstrom
2010-04-23 22:34                       ` erik quanstrom
2010-04-24 18:59                         ` Bakul Shah
2010-04-24 21:47                           ` Charles Forsyth
2010-04-25  0:31                           ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100423200815.03B385B4A@mail.bitblocks.com \
    --to=bakul+plan9@bitblocks.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).