public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/30364] [4.1/4.2/4.3 Regression] Wrong variable ranges due to constant folding
Date: Fri, 05 Jan 2007 20:32:00 -0000	[thread overview]
Message-ID: <20070105203238.1088.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30364-7904@http.gcc.gnu.org/bugzilla/>



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-01-05 20:32 -------
>From C99, 5.1.2.3/14:
14 EXAMPLE 6 To illustrate the grouping behavior of expressions, in the
following fragment
int a, b;
/* ... */
a = a + 32760 + b + 5;
the expression statement behaves exactly the same as
a = (((a + 32760) + b) + 5);
due to the associativity and precedence of these operators. Thus, the result of
the sum (a + 32760) is
next added to b, and that result is then added to 5 which results in the value
assigned to a. On a machine in
which overflows produce an explicit trap and in which the range of values
representable by an int is
[&#8722;32768, +32767], the implementation cannot rewrite this expression as
a = ((a + b) + 32765);
since if the values for a and b were, respectively, &#8722;32754 and &#8722;15,
the sum a + b would produce a trap
while the original expression would not; nor can the expression be rewritten
either as
a = ((a + 32765) + b);
or
a = (a + (b + 32765));
since the values for a and b might have been, respectively, 4 and &#8722;8 or
&#8722;17 and 12. However, on a machine
in which overflow silently generates some value and where positive and negative
overflows cancel, the
above expression statement can be rewritten by the implementation in any of the
above ways because the
same result will occur.

That is most explict thing about overflow and groupping.  In C, every
expression has an implicate parenthesises.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30364


  parent reply	other threads:[~2007-01-05 20:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-04  9:16 [Bug c/30364] New: " guillaume dot melquiond at ens-lyon dot fr
2007-01-04  9:30 ` [Bug middle-end/30364] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-01-04 10:15 ` guillaume dot melquiond at ens-lyon dot fr
2007-01-04 10:23 ` pinskia at gcc dot gnu dot org
2007-01-04 10:26 ` pinskia at gcc dot gnu dot org
2007-01-04 10:40 ` pinskia at gcc dot gnu dot org
2007-01-04 11:25 ` guillaume dot melquiond at ens-lyon dot fr
2007-01-05 19:06 ` jakub at gcc dot gnu dot org
2007-01-05 19:58 ` pinskia at gcc dot gnu dot org
2007-01-05 20:32 ` pinskia at gcc dot gnu dot org [this message]
2007-01-05 21:06 ` gdr at integrable-solutions dot net
2007-01-05 21:09 ` gdr at integrable-solutions dot net
2007-02-05  5:50 ` mmitchel at gcc dot gnu dot org
2007-02-14  9:03 ` mmitchel at gcc dot gnu dot org
2007-02-21 14:24 ` rguenth at gcc dot gnu dot org
2007-02-28 21:57 ` rguenth at gcc dot gnu dot org
2007-02-28 23:03 ` [Bug middle-end/30364] [4.1/4.2 " rguenth at gcc dot gnu dot org
2007-03-05 13:15 ` rguenth at gcc dot gnu dot org
2007-03-05 13:17 ` [Bug middle-end/30364] [4.1 " rguenth at gcc dot gnu dot org
2007-03-15 18:09 ` rguenth at gcc dot gnu dot org
2007-03-15 18:10 ` rguenth at gcc dot gnu dot org
2007-08-24 16:33 ` jakub at gcc dot gnu dot org
2007-08-24 16:40 ` rguenth at gcc dot gnu dot org

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=20070105203238.1088.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).