When individual bit field members of a struct/class are declared as volatile, the generated code may not treat them as volatile (code varies with -O and -m<processor> choices). Non-bit field volatile members and bit field members of volatile structs are always treated as volatile. The problem can be worked around by declaring the entire structure volatile. m68k-elf-g++ and m68k-elf-gcc both generate the bad code when compiling C++, however, m68k-elf-gcc generates good code when compiling the same test code as C. I will attach a test.c file which can be compiled as C or C++.
-- Summary: volatile struct bit fields not treated as volatile Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Steve at Zook dot com GCC host triplet: i686-pc-cygwin GCC target triplet: m68k-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33068