public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "borntraeger at de dot ibm dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/45017]  New: miscompile with bitfield and optimization
Date: Wed, 21 Jul 2010 11:23:00 -0000	[thread overview]
Message-ID: <bug-45017-18712@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2010-07-21 11:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 11:23 borntraeger at de dot ibm dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-45017-18712@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).