public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31072]  New: Wrong code for volatile var with initalization and optimization
@ 2007-03-07 15:38 a_fisch at gmx dot de
  2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: a_fisch at gmx dot de @ 2007-03-07 15:38 UTC (permalink / raw)
  To: gcc-bugs

I tracked it down to the following code, which is not compiled as expected, if
optimization (> O1) is turned on. 

Contents of fg.c:
---8<------8<---------8<---
extern volatile int ReadyFlag_NotProperlyInitialized;

volatile int ReadyFlag_NotProperlyInitialized=1;
volatile int ReadyFlag_InitializationOk=1;
---8<------8<---------8<---

My command line for GCC 4.3-20070223:
  powerpc-elf-gcc -O1 -S -o fg_O1.s fg.i  


In the generated assembler output, the variable ReadyFlag_InitializationOk is
placed in section .sbss (instead of .sdata) an is initialized with 0 instead of
1. 
ReadyFlag_InitializationOk is initialized as expected. The only difference is
the extern declaration for ReadyFlag_NotProperlyInitialized.

Contents of fg_O1.s:
---8<------8<---------8<---
        .file   "fg.c"
        .globl ReadyFlag_NotProperlyInitialized
        .globl ReadyFlag_InitializationOk
        .section        .sbss,"aw",@nobits
        .align 2
        .type   ReadyFlag_NotProperlyInitialized, @object
        .size   ReadyFlag_NotProperlyInitialized, 4
ReadyFlag_NotProperlyInitialized:
        .zero   4
        .section        .sdata,"aw",@progbits
        .align 2
        .type   ReadyFlag_InitializationOk, @object
        .size   ReadyFlag_InitializationOk, 4
ReadyFlag_InitializationOk:
        .long   1
        .ident  "GCC: (GNU) 4.3.0 20070223 (experimental)"
---8<------8<---------8<---

gcc-3.4.6 built with the same system (same build, host and target) is ok!
gcc-4.1.2 built with the same system (same build, host and target) is ok!

gcc-4.2-20070221 shows the same error as 4.3-20070223 (both built as above)


-- 
           Summary: Wrong code for volatile var with initalization and
                    optimization
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: a_fisch at gmx dot de
 GCC build triplet: mingw32
  GCC host triplet: mingw32
GCC target triplet: powerpc-elf


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-03-09  2:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
2007-03-07 15:44 ` a_fisch at gmx dot de
2007-03-07 17:11 ` pinskia at gcc dot gnu dot org
2007-03-07 17:44 ` a_fisch at gmx dot de
2007-03-07 22:33 ` [Bug target/31072] [4.3 Rgression] " pinskia at gcc dot gnu dot org
2007-03-07 22:34 ` [Bug target/31072] [4.2/4.3 " pinskia at gcc dot gnu dot org
2007-03-08  3:41 ` [Bug c/31072] " pinskia at gcc dot gnu dot org
2007-03-08 19:15 ` pinskia at gcc dot gnu dot org
2007-03-09  0:32 ` pinskia at gcc dot gnu dot org
2007-03-09  0:33 ` [Bug c/31072] [4.2 " pinskia at gcc dot gnu dot org
2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
2007-03-09  2:50 ` pinskia at gcc dot gnu dot org

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).