This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/71492] New: Read from volatile pointer is removed
- From: "stettberger at dokucode dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 Jun 2016 09:24:32 +0000
- Subject: [Bug middle-end/71492] New: Read from volatile pointer is removed
- Auto-submitted: auto-generated
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