There are example console programs for volatile
keyword in C++, in which removing volatile
changes the output of the program. For example if the iterators of some for
loops are volatile, the execution time is noticeably much longer; and this clearly proves that volatile
has prevented an optimization.
In C#, I could not find an example of volatile
in which an optimization is noticeably canceled. Do you have such an example working in Visual Studio compiler?
I mean an example in which removing the volatile
keyword changes something in the output of the program.