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