Yes. This is what the storage type "volatile" is for. If it's a register or something that may change without your program doing it, i.e. a memory mapped device register, you want to declare it as volatile. In general your writes are safe, but if the compiler thinks you haven't modified it since your last write, it may very well optimize away the read. As to what the specific levels of optimization would do or not do, I'd have to look it up myself, so it's better if you go straight to the source. HTH, Gerard Bras -----Original Message----- From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx]On Behalf Of Ryan Hajdaj Sent: Tuesday, October 19, 2004 3:52 PM To: gcc-help@xxxxxxxxxxx Subject: Optimization and reading/writing to register locations This is sort of vague, but in embedded applications that read from or write to particular memory addresses (ie hardware registers), is there any risk of these reads/writes being "optimized away"? Ie, if I have this in the code: int i; *((int *) 0xffee0000) = 5; i = *((int *) 0xffee0000); Are all lines guaranteed to execute with -O, -O2, and -O3? Thanks very much. -Ryan Hajdaj _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com