https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65449

            Bug ID: 65449
           Summary: -fstrict-volatile-bitfields affects volatile pointer
                    dereference and produce wrong codes
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ma.jiang at zte dot com.cn

Hi,all.
   It seems that  -fstrict-volatile-bitfields  can affect volatile pointer
dereference. However, the gcc manual said this option should only affect
accesse to bit-fields or structure fields.
Compiling the test case: 
char mt[20];
void main()
{
    void *mm=&(mt[1]);
  *((volatile int *)mm)=4;
}
 with -O2 -mstrict-align -fstrict-volatile-bitfields on PPC. We can see that 
"*((volatile int *)mm)=4 " is done by a single stw. Beware that -mstrict-align
means  a non-aligned memory access is disallowed, and &(mt[1]) is obviously not
a address aligned to 4-bytes boundary.  The compiler should have no reasons to
produce a unaligned stw when mstric-align is on.

Further more,compiling with -O2 -mstrict-align -fno-strict-volatile-bitfields,
the compiler will produce four lbz/stb pairs for "*((volatile int *)mm)=4;".
This is  ridiculous as the C standard does not require the read, and surely no
performance benefits could grain from these lbz.

Reply via email to