From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1530 invoked by alias); 21 Jul 2010 11:23:19 -0000 Received: (qmail 1474 invoked by uid 48); 21 Jul 2010 11:23:07 -0000 Date: Wed, 21 Jul 2010 11:23:00 -0000 Subject: [Bug middle-end/45017] New: miscompile with bitfield and optimization X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "borntraeger at de dot ibm dot com" 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 X-SW-Source: 2010-07/txt/msg02206.txt.bz2 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 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