This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47391] New: read from const volatile incorrectly eliminated


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

           Summary: read from const volatile incorrectly eliminated
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: regehr@cs.utah.edu


I'm using r169046 on x86 Linux.

  The problem is that this code:

const volatile int g_2 = 1;
int g_1 = 0;

void func_1 (void) {
   g_1 = g_2;
}

int main (void) {
  func_1();
  return 0;
}

  Compiled like this:

current-gcc -O2 -S small.c

  Gives this main():

main:
    movl    $1, g_1
    xorl    %eax, %eax
    ret

The load from g_2 shouldn't have been removed.  Oddly, the load is not
eliminated from func_1(), nor is it eliminated from main if we inline the
function by hand.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]