On Wed, Feb 2, 2011 at 6:55 PM, Stefan Schulze Frielinghaus <stefan@xxxxxxxxxxxx> wrote: >> But have you tried comparing the outputs of what -O0 outputs to say -O2 ? > > The problem with using anything else then -O0 is that it enables other > optimization techniques, e.g. constant propagation (the example of the > first mail would be scaled down to a simple "return 0;") which I do not > want. Therefore, I would like to compile my code without any > optimizations except register allocation. Hi Stefan, keep in mind that "register" keyword is only a **hint** given to compiler to do register optimization. Compiler is not obliged to listen to your hints, and it probably does not do so without optimization turned on (I am not sure if it can be forced). BTW, you should also keep in mind that ANSI C does not allow for taking the address of a register object; this restriction does not apply to C++. However, if the address-of operator (&) is used on an object, the compiler must put the object in a location for which an address can be represented. In practice, this means in memory instead of in a register. Because of this restriction GCC will ignore the register keyword on variables whos address is taken at any point in the program. So, ensure that somewhere in your code you are not using the addresses operator on these variables. BR, Drasko