I have an interesting question (to me at least) about using volatile to prevent variables being optimised away. This is for the purpose of successful debugging / single stepping, etc.
I don't use -O0 because my experience is that it actually corrupts code even though it allows successful debugging.
So assuming I write correct C code and use volatile to allow successful single stepping through the code (after compiling using -O1), if afterwards I removed all the volatile keywords to allow the code to be optimised, should the code run "effectively" the same once programmed into the AVR.
My code is normally small so the reduction in code speed will probably be negligible with my use of volatile on a few variables, but I am curious about the effects of removing volatile.