Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!rutgers!rochester!pt.cs.cmu.edu!g.gp.cs.cmu.edu!butcher From: butcher@g.gp.cs.cmu.edu (Lawrence Butcher) Newsgroups: gnu.gcc.bug Subject: constant folding bug Message-ID: <4973@pt.cs.cmu.edu> Date: 11 May 89 06:26:03 GMT Distribution: usa Organization: Carnegie-Mellon University, CS/RI Lines: 52 gcc 1.35 on a 60820 sun running sun unix 3.5. gcc seems to constant fold differently than several other c compilers in this funny case. I can sort of see it either way. If constants are considered ints unless otherwise specified, gcc gets this wrong. main() { if (0xFFFFF000 < 0x00000FFF) /* If 2's comp, -256 < 255 */ printf ("(no type)0xFFFFF000 < (no type)0x00000FFF\n"); else printf ("(no type)0xFFFFF000 >= (no type)0x00000FFF\n"); if (0xFFFFF000L < 0x00000FFFL) /* If 2's comp, -256 < 255 */ printf ("0xFFFFF000L < 0x00000FFFL\n"); else printf ("0xFFFFF000L >= 0x00000FFFL\n"); if ((short)0xFFFFF000 < (short)0x00000FFF) printf ("(short)0xFFFFF000 < (short)0x00000FFF\n"); else printf ("(short)0xFFFFF000 >= (short)0x00000FFF\n"); if ((unsigned)0xFFFFF000 < (unsigned)0x00000FFF) printf ("(unsigned)0xFFFFF000 < (unsigned)0x00000FFF\n"); else printf ("(unsigned)0xFFFFF000 >= (unsigned)0x00000FFF\n"); if ((signed)0xFFFFF000 < (signed)0x00000FFF) printf ("(signed)0xFFFFF000 < (signed)0x00000FFF\n"); else printf ("(signed)0xFFFFF000 >= (signed)0x00000FFF\n"); if ((int)0xFFFFF000 < (int)0x00000FFF) printf ("(int)0xFFFFF000 < (int)0x00000FFF\n"); else printf ("(int)0xFFFFF000 >= (int)0x00000FFF\n"); if ((long)0xFFFFF000 < (long)0x00000FFF) printf ("(long)0xFFFFF000 < (long)0x00000FFF\n"); } results are: (no type)0xFFFFF000 >= (no type)0x00000FFF // which I do not expect 0xFFFFF000L >= 0x00000FFFL // likewise seems wrong (short)0xFFFFF000 < (short)0x00000FFF (unsigned)0xFFFFF000 >= (unsigned)0x00000FFF (signed)0xFFFFF000 < (signed)0x00000FFF (int)0xFFFFF000 < (int)0x00000FFF (long)0xFFFFF000 < (long)0x00000FFF --