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 c/25125]  New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type
Date: Sun, 27 Nov 2005 17:39:00 -0000	[thread overview]
Message-ID: <bug-25125-6528@http.gcc.gnu.org/bugzilla/> (raw)

unsigned short f(unsigned short a)
{
  short c = a;
  if (c >0) return 0;
  short b = ((int)a) + - (int)32768;
  return b;
}

int main(void)
{
  printf("%d\n", f(32769));
}
---

Compile with -O2 and we get the wrong result.  We should get 1 but instead we
get 32768.  Note this was exposed by VRP but VRP is doing what it is given o
it.


-- 
           Summary: [4.1/4.2 Regression] (short) ((int)(unsigned short) +
                    (int)) is done in the wrong type
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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


             reply	other threads:[~2005-11-27 17:39 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-27 17:39 pinskia at gcc dot gnu dot org [this message]
2005-11-27 17:40 ` [Bug c/25125] " pinskia at gcc dot gnu dot org
2005-11-27 17:42 ` pinskia at gcc dot gnu dot org
2005-11-27 17:45 ` rguenth at gcc dot gnu dot org
2005-11-27 17:47 ` rguenth at gcc dot gnu dot org
2005-11-27 18:03 ` [Bug middle-end/25125] " pinskia at gcc dot gnu dot org
2005-11-28 21:48 ` janis at gcc dot gnu dot org
2005-12-04  4:21 ` pinskia at gcc dot gnu dot org
2005-12-17 17:26 ` kazu at gcc dot gnu dot org
2005-12-18 15:51 ` steven at gcc dot gnu dot org
2005-12-19 18:29 ` mmitchel at gcc dot gnu dot org
2005-12-19 18:29 ` mmitchel at gcc dot gnu dot org
2005-12-19 18:36 ` pinskia at gcc dot gnu dot org
2005-12-19 18:38 ` kazu at codesourcery dot com
2005-12-19 18:40 ` mark at codesourcery dot com
2005-12-26 23:00 ` kazu at gcc dot gnu dot org
2005-12-26 23:01 ` [Bug middle-end/25125] [4.1 " kazu at gcc dot gnu dot org
2005-12-27  1:07 ` danglin at gcc dot gnu dot org
2005-12-27  1:41 ` dave at hiauly1 dot hia dot nrc dot ca
2005-12-27 11:16 ` steven at gcc dot gnu dot org
2005-12-27 15:00 ` dave at hiauly1 dot hia dot nrc dot ca
2005-12-27 16:59 ` kazu at gcc dot gnu dot org
2005-12-27 17:06 ` dave at hiauly1 dot hia dot nrc dot ca
2005-12-27 19:27 ` dave at hiauly1 dot hia dot nrc dot ca
2005-12-27 22:35 ` dave at hiauly1 dot hia dot nrc dot ca
2006-01-09  4:37 ` kazu at gcc dot gnu dot org
2006-01-09  4:40 ` kazu at gcc dot gnu dot org
2006-01-09  4:42 ` kazu at gcc dot gnu dot org
2006-01-09  4:43 ` kazu at gcc dot gnu dot org
2006-02-26 14:44 ` dorit 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=bug-25125-6528@http.gcc.gnu.org/bugzilla/ \
    --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).