Problem with reordering of memory accesses
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Wed Oct 18 09:53:00 GMT 2000
At 18:26 18.10.00, Michael Schwingen wrote:
>On Tue, Oct 17, 2000 at 11:30:42AM -0700, Geoff Keating wrote:
> > If you can provide an example, it might be able to be fixed...
>
>This turned out to be quite easy:
>
>typedef struct
>{
> int x1;
> short x2;
> volatile void *x3;
> void *x4;
> volatile void *x5;
> void *x6;
> void *x7;
>} foo;
>
>void TestFnc(foo *p)
>{
> p->x5 = 0;
> p->x3 = 0;
>}
I don't see a reason why gcc should order these accesses. Unless you meant
to write:
typedef struct {
int x1;
short x2;
void * volatile x3;
void *x4;
void * volatile x5;
void *x6;
void *x7;
} foo;
or:
typedef volatile struct {
int x1;
short x2;
void *x3;
void *x4;
void *x5;
void *x6;
void *x7;
} foo;
which do the ordering as expected.
Franz.
More information about the Gcc
mailing list