http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53085
--- Comment #4 from brag <unixoid2003 at mail dot ru> 2012-04-24 12:27:29 UTC
---
Alexander Monakov, As for me it's ok to treat whole struct as non-volatile even
if it has a volatile members when doing smth like this:
struct ss0 a,b;
a=b;
a=b;
Simple example with class:
class aa{
void f();
private:
volatile int a;
};
void aa::f(){
a=0xff;
a=0xff;
}
arm-none-eabi-gcc -O2 -mcpu=cortex-m3 -mthumb -c test.cpp
gcc-4.6.1 compiled:
00000000 <_ZN2aa1fEv>:
0: 23ff movs r3, #255 ; 0xff
2: 6003 str r3, [r0, #0]
4: 6003 str r3, [r0, #0]
6: 4770 bx lr
The code is right.
gcc-4.7.0 compiled:
00000000 <_ZN2aa1fEv>:
0: 23ff movs r3, #255 ; 0xff
2: 6003 str r3, [r0, #0]
4: 4770 bx lr
6: bf00 nop
The code is wrong. It's not ok to write once 'volatile int a' member.