From what I understand, the 'volatile' modifier in C# has two effects:
- Inserts fences as necessary for the target processor
- Prevents certain compiler optimizations
On x86 / amd64, (1) is irrelevant. Those processors don't require fences for volatile semantics. (ia64 is different, though.)
So, we are down to (2). But, for examples that I tried, volatile does not make any difference to the jit-ted assembly.
My question is: Can you give an example of a C# code sample where adding a 'volatile' modifier on a field results in different jit-ted assembly code?