This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25125] New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Nov 2005 17:39:04 -0000
- Subject: [Bug c/25125] New: [4.1/4.2 Regression] (short) ((int)(unsigned short) + (int)) is done in the wrong type
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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