public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: Joe Buck <jbuck@synopsys.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Suggested warning: "negating an expression of unsigned type does not yield a negative value"
Date: Mon, 06 Oct 2003 17:52:00 -0000	[thread overview]
Message-ID: <87wubitfsx.fsf@student.uni-tuebingen.de> (raw)
In-Reply-To: <20031006104759.A13735@synopsys.com>

Joe Buck <jbuck@synopsys.com> writes:

> On Mon, Oct 06, 2003 at 06:11:05PM +0200, Falk Hueffner wrote:
> > Joe Buck <jbuck@synopsys.com> writes:
> > > The C and C++ standards require that unsigned values obey modulo 2**N
> > > arithmetic, so the value of -x is rigorously defined.
> > 
> > Sure it is. But it is not what is intended. Example: x = 5, then
> > -x=4294967291, i.e., p will be advanced by 4294967291 bytes, which is
> > way beyond the legal range of p, but happens to work anyway on 32 bit
> > architectures (but not on 64 bit architectures).
> 
> Good catch.  It seems that the real problem is not negation of
> unsigned values, but negation followed by extension to a potentially
> larger word size.  If you can figure out how to warn specifically
> about that, it might be worth adding.  But it would be tricky.

I'll give it a try, but I'm not sure how to do that right now, warning
about it every time was a lot easier :)

-- 
	Falk

      reply	other threads:[~2003-10-06 17:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-06 12:46 Falk Hueffner
2003-10-06 16:00 ` Joe Buck
2003-10-06 16:11   ` Falk Hueffner
2003-10-06 17:23     ` Jamie Lokier
2003-10-06 17:48     ` Joe Buck
2003-10-06 17:52       ` Falk Hueffner [this message]

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=87wubitfsx.fsf@student.uni-tuebingen.de \
    --to=falk.hueffner@student.uni-tuebingen.de \
    --cc=gcc@gcc.gnu.org \
    --cc=jbuck@synopsys.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).