We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I AM NOT UNDERSTANDING THE SITUATION WHEN SHOULD I USE "VOLATILE" WITH VARIABLES ???
It seems to depend a lot on gcc version. Most probably, only versions before 4.x keep empty loops.
Test with empty loop and -O3:
gcc 2.95.4 leaves loop. gcc 3.0.4 leaves loop. gcc 3.3.1 leaves loop. gcc 3.3.5 leaves loop. gcc 3.3.6 leaves loop. gcc 4.1.2 strips loop.