public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35729]  New: const volatile variable accessed that should not be
@ 2008-03-28  3:05 regehr at cs dot utah dot edu
  2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: regehr at cs dot utah dot edu @ 2008-03-28  3:05 UTC (permalink / raw)
  To: gcc-bugs

This is for "gcc version 4.3.0 (GCC)" 

func_1() here should never load from g_361 since the loop body never executes:

  const volatile int g_361 = 3L;
  volatile int g_2 = 0L;
  void func_1 (void) {
    for (g_2 = 0; g_2 > 10; g_2++)
      {
        int l_357 = g_361;
      }
  }

However when compiled with "gcc -Os -S foo.c" we get the following output which
does load from g_361:

        .file   "foo.c"
        .text
.globl func_1
        .type   func_1, @function
func_1:
        pushl   %ebp
        movl    %esp, %ebp
        movl    $0, g_2
        movl    g_361, %eax
        jmp     .L2
.L3:
        movl    g_2, %eax
        incl    %eax
        movl    %eax, g_2
.L2:
        movl    g_2, %eax
        cmpl    $10, %eax
        jg      .L3
        popl    %ebp
        ret
        .size   func_1, .-func_1
.globl g_361
        .data
        .align 4
        .type   g_361, @object
        .size   g_361, 4
g_361:
        .long   3
.globl g_2
        .bss
        .align 4
        .type   g_2, @object
        .size   g_2, 4
g_2:
        .zero   4
        .ident  "GCC: (GNU) 4.3.0"
        .section        .note.GNU-stack,"",@progbits

At -O0, -O1, and -O2 there is no problem.


-- 
           Summary: const volatile variable accessed that should not be
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: regehr at cs dot utah dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2009-11-29 16:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
2008-03-30 15:02 ` rakdver at gcc dot gnu dot org
2008-03-31 14:21 ` rakdver at gcc dot gnu dot org
2008-04-01  9:40 ` dominiq at lps dot ens dot fr
2008-04-01 10:28 ` dominiq at lps dot ens dot fr
2008-04-27 17:18 ` danglin at gcc dot gnu dot org
2008-05-25 18:04 ` ghazi at gcc dot gnu dot org
2008-10-16 21:34 ` sje at cup dot hp dot com
2008-11-08  1:36 ` danglin at gcc dot gnu dot org
2008-11-08 20:20 ` ebotcazou at gcc dot gnu dot org
2008-12-02 14:22 ` krebbel at gcc dot gnu dot org
2009-01-05 23:15 ` sje at cup dot hp dot com
2009-01-17  2:50 ` ghazi at gcc dot gnu dot org
2009-01-19 18:53 ` ubizjak at gmail dot com
2009-11-29 16:22 ` ghazi at gcc dot gnu dot org
2009-11-29 16:38 ` rguenth 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).