public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dhazeghi at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/57347] New: wrong code for bitfield on x86_64-linux at -Os and above
Date: Mon, 20 May 2013 23:28:00 -0000	[thread overview]
Message-ID: <bug-57347-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 57347
           Summary: wrong code for bitfield on x86_64-linux at -Os and
                    above
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The following code is miscompiled on x86_64-linux with gcc trunk and 4.8 at -Os
and above optimization level.  It works correctly with gcc 4.7 (outputs 1).

$ gcc-trunk -v
gcc version 4.9.0 20130520 (experimental) [trunk revision 199099] (GCC) 
$ gcc-trunk -O1 wrong.c 
$ ./a.out 
1
$ gcc-4.7 -Os wrong.c 
$ ./a.out 
1
$ gcc-trunk -Os wrong.c 
$ ./a.out 
0
$

-----------------
int printf(const char *, ...);

struct S1 {
  int f0;
  int f1 : 10;
  int f2 : 13;
};

int i;
int *j = &i;

static void foo(struct S1 s) {
  int *p;
  int l[88];
  int **pp = &p;
  *pp = &l[1];
  l[0] = 1;
  *j = 1 && s.f2;
}

int main(void) {
  struct S1 s = { 0, 0, 1 };
  foo(s);
  printf("%d\n", i);
  return 0;
}


             reply	other threads:[~2013-05-20 23:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 23:28 dhazeghi at yahoo dot com [this message]
2013-05-21  6:32 ` [Bug rtl-optimization/57347] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-05-21 12:26 ` jakub at gcc dot gnu.org
2013-05-21 13:47 ` jamborm at gcc dot gnu.org
2013-05-23 13:47 ` [Bug middle-end/57347] " jamborm at gcc dot gnu.org
2013-05-23 13:47 ` jamborm at gcc dot gnu.org

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-57347-4@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).