Static local variable initialization in VS2013
There’s this bug, which I caught the other day: static local variables aren’t initialized in a thread-safe manner in Visual C++ 2013. Consider the code for singleton initialization:
Singleton& getInstance()
{
static Singleton instance;
return instance;
}
C++11 requires compilers to generate a thread-safe assembly in this case. So does gcc, and so expected I. However, Microsoft compiler seems to ignore this requirement. For instance, people talk about this on gamedev. Be careful!