Volatile const members of a struct are not generating a load when read while volatile non-const members are loaded (volatile const objects outside of a structure do generate a load when read). const members of a volatile struct generate two loads when read (strange code being produced in this case). This has been seen in 3.3.3 (for x86 and m68k targets) and 3.4.4 (for m68k targets, untested on x86). The attached test.cpp file when compiled gcc -c -save-temps test.cpp on 3.3.3 under cygwin (x86 target) produces the attached test.s output. Multiple stores on volatile const members of structs get optimized away as well (this is not demonstrated in the attached test code). Note that when the test code is compiled as C rather than C++, correct code gets produced.
-- Summary: volatile const members of structures not treated as volatile Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Steve at Zook dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23702