From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32397 invoked by alias); 8 Apr 2004 22:50:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32387 invoked by uid 48); 8 Apr 2004 22:50:20 -0000 Date: Thu, 08 Apr 2004 22:50:00 -0000 From: "aweiner at lsil dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040408225018.14896.aweiner@lsil.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop X-Bugzilla-Reason: CC X-SW-Source: 2004-04/txt/msg00799.txt.bz2 List-Id: Version: powerpcle-440-eabi-gcc (GCC) 3.4.0 20040225 (prerelease) When using the "-Os" compiler option, the optimizer will improperly optimize- out the assignment of a structure field if that field is the FIRST field within the structure AND the assignemnt is within an infinite-loop block. Example: typedef struct { int a; int b; } TEST; TEST t; /* also fails if 't' is local to foo() */ void foo(void) { for (;;) { /* while (1) also fails */ t.a = 5; } } Code generated: 00000000 : 0: 00 00 00 48 b 0 Any of the following changes to the above source cause the compiler to generate the proper code: * Assign second field ('b') of structure rather than first ('a') * Move assignemnt outside of "for(;;)" loop * Access field through pointer rather than instance * Call to a non-inlined function is made within loop block * Compile without "-Os" Below is the compiler output when the second field ('b') is assigned instead of the first ("t.b = 5" vs. "t.a = 5"): 00000000 : 0: 00 00 20 3d lis r9,0 4: 05 00 00 38 li r0,5 8: 00 00 29 39 addi r9,r9,0 c: 04 00 09 90 stw r0,4(r9) 10: fc ff ff 4b b c -- Summary: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P1 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aweiner at lsil dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14896