Imagine this C# code in some method:
SomeClass.SomeGlobalStaticDictionary = new Dictionary<int, string>()
{
{0, "value"},
};
Let's say no one is using any explicit memory barriers or locking to access the dictionary.
If no optimization takes place, then the global dictionary should be either null (initial value) or a properly constructed dictionary with one entry.
The question is: Can the effect of the Add call and assigning to SomeGlobalStaticDictionary be reordered such that some other thread would see an empty non-null SomeGlobalStaticDictionary (or any other invalid partially constructed dictionary?)
Does the answer change if SomeGlobalStaticDictionary is volatile?
After reading http://msdn.microsoft.com/en-us/magazine/jj863136.aspx (and also its second part) I learned that in theory just because one variable is assigned in source code other threads might see it differently due to many reasons. I looked at the IL code but the question is whether the JIT compiler and/or CPU are allowed to not "flush" the effect of the Add call to other threads before the assignment of the SomGlobalStaticDictionary.