public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robert Dewar <dewar@gnat.com>
To: "Thomas R. Truscott" <trt@cs.duke.edu>
Cc: gcc@gcc.gnu.org
Subject: Re: Warning flags for unsigned operations (unsafe)
Date: Wed, 22 Sep 2004 16:18:00 -0000	[thread overview]
Message-ID: <41519C17.10804@gnat.com> (raw)
In-Reply-To: <200409221435.i8MEZYX0009371@minie.cs.duke.edu>

Thomas R. Truscott wrote:
>  > I couldn't find out if gcc had a 
>  > warning flag for unsigned operation. For example, even the linear 
>  > interpolation on [a,b] can be tricky to code:
>  > 
>  >  c = a + t * (b - a);  //unsafe
> 
> Not for this situation.  I think a warning would be appropriate
> when an unsigned quantity involving subtraction
> is widened or converted to double.

Why? The semantics are reasonable, well defined, and expected.
One assumes that in this case either the code expects the wrap
semantics (less likely) or, more likely, knows that the quantity
b-a will be non-negative.

I see nothing special about being widened or converted to double.

  reply	other threads:[~2004-09-22 15:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22 15:38 Thomas R. Truscott
2004-09-22 16:18 ` Robert Dewar [this message]
2004-09-22 16:31 ` Robert Dewar
2004-09-22 16:53 ` Dave Korn
  -- strict thread matches above, loose matches on Subject: below --
2004-09-22  5:33 Mathieu Malaterre
2004-09-22 14:57 ` Dave Korn
2004-09-22 15:12   ` Robert Dewar
2004-09-22 20:50   ` Luca Masini
2004-09-23  1:37     ` Mathieu Malaterre
2004-09-24  6:20 ` Giovanni Bajo
2004-09-24  6:31   ` Mathieu Malaterre

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=41519C17.10804@gnat.com \
    --to=dewar@gnat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=trt@cs.duke.edu \
    /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).