public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/44828] possible integer wrong code bug
Date: Tue, 06 Jul 2010 09:33:00 -0000	[thread overview]
Message-ID: <20100706093317.3751.qmail@sourceware.org> (raw)
In-Reply-To: <bug-44828-12544@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from jakub at gcc dot gnu dot org  2010-07-06 09:33 -------
Not sure whether the testcase is valid or not.  The multiplication using char
variables on both sides (and likewise for result) is: -54 * -56 (= 3024),
but (char) 3024 is -48.  For int that would be clear undefined behavior, but
for char the multiplication is promoted to int, so it is (char) (int * int).
*.ccp1 has:
  char D.2741;
  char D.2741;
  char si2;
  int D.2727;
  char D.2726;
  int a.0;

<bb 2>:
  a.0_2 = a;
  D.2726_3 = (char) a.0_2;
  D.2727_4 = (int) D.2726_3;
  si2_11 = (char) D.2727_4;
  D.2741_12 = si2_11 * -56;
  D.2741_13 = D.2741_12;
  D.2741_7 = D.2741_13;
  if (D.2741_7 > 0)

but forwprop1 uses if (si2_11 < 0) test instead.  If the testcase is valid, we
shouldn't assume undefined overflow for char and short operations.


-- 


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


  parent reply	other threads:[~2010-07-06  9:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-05 22:52 [Bug c/44828] New: " regehr at cs dot utah dot edu
2010-07-06  9:25 ` [Bug c/44828] " jakub at gcc dot gnu dot org
2010-07-06  9:33 ` jakub at gcc dot gnu dot org [this message]
2010-07-06 10:35 ` rguenth at gcc dot gnu dot org
2010-07-06 13:38 ` rguenth at gcc dot gnu dot org
2010-07-06 13:41 ` [Bug c/44828] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-07-06 14:11 ` regehr at cs dot utah dot edu
2010-07-07 22:52 ` bergner at gcc dot gnu dot org
2010-07-08  4:12 ` bergner at gcc dot gnu dot org
2010-07-08  4:19 ` bergner at gcc dot gnu dot org
2010-07-08  7:47 ` jakub at gcc dot gnu dot org
2010-07-08 11:57 ` rguenth at gcc dot gnu dot org
2010-07-08 11:57 ` [Bug c/44828] [4.3/4.4 " rguenth at gcc dot gnu dot org
2010-07-08 14:18 ` bergner at gcc dot gnu dot org
2010-07-27 11:24 ` 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=20100706093317.3751.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).