This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/25125] New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]