"Hofman, Gertjan (BI35)" <Gertjan.Hofman@xxxxxxxxxxxxx> writes: > I have noticed that any optimization flag (-0 and up) removes > consequtive read/write lines i.e. > > *((unsigned char *) virtaddr) = 0xF0; > *((unsigned char *) virtaddr) = 0xFE; > > Even though they are writing different data to memory. Kind of scary. > With -O0, the code runs as anticipated. This is normal. Think about use with a normal pointer. The first assignment is overwritten by the second before anything could possibly read it. You need to use a volatile qualified pointer here. This is standard C; it has nothing to do with gcc as such. > In order to find out what is causing the removal I replaced -O with all > the -fxxxxx options listed in man gcc. This does not replicate the > problem ! In otherwords, -O does more that the sum of all the -fxxx > options. Correct. Some code transformations are controlled only be the presence of the -O option. > 1. Is there a way to have the compiler tell me which options are being > turned on using -O ? There will be in gcc 4.3, but it won't help answer your actual question. > 2. Are there architecture specific optimizations which are not described > in the man page ? Yes. Many. Ian