The following code does not treat volatile struct members as volatile,
assuming such declarations are valid; if not would exect a warning:

typedef struct {
  volatile int a;
  volatile int b;
  } s;

int main (void){

  s x = {0, 1};
  s y = {2, 3};
  
  x = y;
  y = x;
  
  return x.a + y.a;

}

generates:

000000c6 <main>:
  volatile int a;
  volatile int b;
  } s;

int main (void){
  c6:   cf ef           ldi     r28, 0xFF       ; 255
  c8:   d0 e1           ldi     r29, 0x10       ; 16
  ca:   de bf           out     0x3e, r29       ; 62
  cc:   cd bf           out     0x3d, r28       ; 61

  s x = {0, 1};
  s y = {2, 3};
  
  x = y;
  y = x;
  
  return x.a + y.a;

}
  ce:   84 e0           ldi     r24, 0x04       ; 4
  d0:   90 e0           ldi     r25, 0x00       ; 0
  d2:   0c 94 6b 00     jmp     0xd6 <_exit>

-- 
           Summary: wrong code for volatile struct members?
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schlie at comcast dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: ppc-apple-darwin7.8
  GCC host triplet: ppc-apple-darwin7.8
GCC target triplet: avr-unknown-unknown


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20127

Reply via email to