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 middle-end/71492] New: Read from volatile pointer is removed


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71492

            Bug ID: 71492
           Summary: Read from volatile pointer is removed
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stettberger at dokucode dot de
  Target Milestone: ---

In the latest GCC (6.1) we observed a regression in our student operating
system. The following minimal working example reproduces the behavior:


int addr = 0xffff;

int checker() {
        int c = *((volatile int *)addr);
        int f = *((volatile int *)addr);
        return f - c;
}


This compiles with -O1 -m32 -Wall -Wextra (without warnings) to:

checker():
        movl    $0, %eax
        ret
addr:
        .long   65535

Is such a cast undefined behavior?

Here the Compiler Explorer link:  https://godbolt.org/g/HBdxip

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