public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/29695]  New: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ? 0x80 : 0 for unsigned char or unsigned short a
@ 2006-11-03 11:24 jakub at gcc dot gnu dot org
  2006-11-03 11:24 ` [Bug middle-end/29695] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-11-03 11:24 UTC (permalink / raw)
  To: gcc-bugs

extern void abort (void);

int
f1 (void)
{
  int a = 128;
  return (a & 0x80) ? 0x80 : 0;
}

int
f2 (void)
{
  unsigned char a = 128;
  return (a & 0x80) ? 0x80 : 0;
}

int
main (void)
{
  if (f1 () != 128)
    abort ();
  if (f2 () != 128)
    abort ();
  return 0;
}

f2 () is miscompiled with -O2 (on x86-64 and ppc at least), returns -128 rather
than 128.


-- 
           Summary: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ?
                    0x80 : 0 for unsigned char or unsigned short a
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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

end of thread, other threads:[~2006-12-01  0:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-03 11:24 [Bug middle-end/29695] New: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ? 0x80 : 0 for unsigned char or unsigned short a jakub at gcc dot gnu dot org
2006-11-03 11:24 ` [Bug middle-end/29695] " jakub at gcc dot gnu dot org
2006-11-03 18:05 ` pinskia at gcc dot gnu dot org
2006-11-05 12:14 ` jakub at gcc dot gnu dot org
2006-11-05 12:18 ` jakub at gcc dot gnu dot org
2006-11-05 12:18 ` jakub at gcc dot gnu dot org
2006-11-06 20:35 ` pinskia at gcc dot gnu dot org
2006-12-01  0:09 ` chaoyingfu 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).