public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25125]  New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type
@ 2005-11-27 17:39 pinskia at gcc dot gnu dot org
  2005-11-27 17:40 ` [Bug c/25125] " pinskia at gcc dot gnu dot org
                   ` (28 more replies)
  0 siblings, 29 replies; 30+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-27 17:39 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2006-02-26 12:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-27 17:39 [Bug c/25125] New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type pinskia at gcc dot gnu dot org
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

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).