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>
Hmm, SRA creates new variables and then goes and makes them renamed which seems wrong.
Subject: Bug 20127 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2005-02-25 01:56:18 Modified files: gcc : ChangeLog tree-sra.c Log message: PR tree-opt/20127 * tree-sra.c (instantiate_element): Copy TREE_THIS_VOLATILE from the type. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7589&r2=2.7590 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-sra.c.diff?cvsroot=gcc&r1=2.52&r2=2.53
Fixed.
Subject: Re: [4.0 Regression] wrong code for volatile struct members Additional Comments From rth at gcc dot gnu dot org 2005-02-25 01:57 > ------- > Fixed. > > -- Thank you.