http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46096
--- Comment #14 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2010-10-20 17:18:33 UTC --- > Maybe just always compiling without optimizations will do? Adding "volatile" is exactly saying "do not optimize this loop", i.e. you get at -O2 what you do at -O0, nothing more, nothing less. This is a language feature that is orthogonal to the synchronization stuff.