The paper Volatiles are Miscompiled, and What to Do about It by Eide and Regehr reports that mishandling of volatiles is a common category of compiler bugs. You should read it if you use volatiles for memory-mapped I/O or thread synchronization . Almost in passing they describe a common programmer error with volatiles:
Inserting a "side-effecting operation" into the loop would also prevent the undesired transformation.
Would inserting any function call within the loop do the trick?
If so, does the Standard require inline functions to do the same?
Originally posted by the Eide and Regehr paper
Would inserting any function call within the loop do the trick?
If so, does the Standard require inline functions to do the same?
Comment