Problem with reordering of memory accesses
Michael Schwingen
michaels@stochastik.rwth-aachen.de
Tue Oct 17 10:15:00 GMT 2000
On Tue, Oct 17, 2000 at 09:51:34AM -0700, Geoff Keating wrote:
> 'volatile' should be the solution you need. If you declare everything
> whose ordering you care about 'volatile', then those variables should
> be changed in the exact order you specify. If not, it's a bug.
Hm. I tried this first, and gcc still reordered them. Only declaring the
pointer to the struct volatile helped in my "real" code. In the small test
case, declaring the elements of the struct volatile was sufficient, though.
> then what GCC can do is read 'a' twice, and then write to c and then
> write to b. I don't think it would ever do this, but it could.
That's what I had expected (although it seems to work currently), and since
the other solution (above) did not seem to work either (I disassembled the
final object file using objdump, to be sure), I was looking for something
better.
cu
Michael
More information about the Gcc
mailing list