This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/22000] New: Read from volatile member of struct is optimized away
- From: "rpedersen at atmel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jun 2005 13:59:26 -0000
- Subject: [Bug tree-optimization/22000] New: Read from volatile member of struct is optimized away
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the code below the read "(int)ptr->b;" gets optimized away.
It appears to be optimized away before the RTL stages, so I guess
it must be because of the tree optimalisation.
I think that the C standard says C that the "name" of variable
becomes an rvalue (the actual value) thus requires that the variable
is accessed.
Code:
struct test {
volatile int a;
volatile int b;
};
int main(int argc, char *argv[]){
struct test *ptr = (struct test *)0x10000000;
ptr->b = 10;
(int)ptr->b;
return 1;
}
--
Summary: Read from volatile member of struct is optimized away
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rpedersen at atmel dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22000