public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/45017]  New: miscompile with bitfield and optimization
@ 2010-07-21 11:23 borntraeger at de dot ibm dot com
  2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: borntraeger at de dot ibm dot com @ 2010-07-21 11:23 UTC (permalink / raw)
  To: gcc-bugs

The following testcase has a different result with 4.6 and -O1/2/3

gcc4.5: all optimizations:
r1: 15 r2: 2

gcc4.6: -O0
r1: 15 r2: 2

gcc4.6: -O1,-O2..
r1: 47 r2: 2

#include <stdio.h>

int tester(char *bytes)
{
        union {
                struct {
                        unsigned int r1:4;
                        unsigned int r2:4;
                } fmt;
                char value[1];
        } ovl;

        ovl.value[0] = bytes[0];
        printf("r1: %d r2: %d\n", ovl.fmt.r1, ovl.fmt.r2);
        return 0;
}

int main()
{
        char buff = 0x2f;
        return tester(&buff);
}


-- 
           Summary: miscompile with bitfield and optimization
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: borntraeger at de dot ibm dot com
 GCC build triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu
  GCC host triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu
GCC target triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu


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


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

end of thread, other threads:[~2010-07-26 10:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
2010-07-22 12:41 ` borntraeger at de dot ibm dot com
2010-07-22 12:42 ` rguenther at suse dot de
2010-07-22 12:59 ` schwab at linux-m68k dot org
2010-07-23  2:49 ` drow at gcc dot gnu dot org
2010-07-23 13:17 ` danglin at gcc dot gnu dot org
2010-07-25 15:44 ` ebotcazou at gcc dot gnu dot org
2010-07-25 16:46 ` mikpe at it dot uu dot se
2010-07-25 16:54 ` borntraeger at de dot ibm dot com
2010-07-25 17:13 ` dave at hiauly1 dot hia dot nrc dot ca
2010-07-25 17:15 ` mikpe at it dot uu dot se
2010-07-26 10:13 ` borntraeger at de dot ibm dot com

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