From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29932 invoked by alias); 20 May 2013 23:28:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29912 invoked by uid 48); 20 May 2013 23:28:09 -0000 From: "dhazeghi at yahoo dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dhazeghi at yahoo dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-05/txt/msg01374.txt.bz2 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; }