Uninitialized static data member of static class
<p>I ran into a weird problem today that I don't really fully understand. Hopefully someone here can help.</p>

<p>The setup is fairly easy. I have a class that has a static member of type std::set. The class has 2 template constructors that differ in the number of arguments only. It's the same behavior for both constructors, so just note that the constructor is templatized, and the constructor is searching and inserting into the std::set.</p>

<p>I'm experiencing the following behavior:
For a static instance of the class, the constructor crashes on the first method called on the static std::set (find()). It looks like the set is not initialized. It seems to me like the constructor is being called before the static member variable is initialized.</p>

<p>Here is a simplified example:</p>

<pre><code>////////// Header File

class ConVar : public IListener
{
  friend EventHandler; // Event Handler auto registers all instances of convar to commands

public: // Auto

  template&lt; typename T &gt;
  ConVar(string const&amp; name, string const&amp; description, T const&amp; default_value );

private:
  static std::set&lt;u32&gt; mRegisteredVars;
};


//////// INL file (included from header)

template&lt; typename T &gt;
ConVar::ConVar(string const&amp; name, string const&amp; description, T const&amp; default_value )
  : mName(name), 
    mhName(name),
    mDescription(description),
    mClamp(false)
 {
    u32 hname = CONSTHASH(name.c_str());
    ErrorIf(mRegisteredVars.find(hname) != mRegisteredVars.end(), "Attempt to create same ConVar multiple times. Note the ConVars are static singletons!");

    *this = default_value;

    mRegisteredVars.insert(hname);

    gCore.Events.Subscribe(mhName, this);
  }

   ///////////// .cpp file

  std::set&lt;u32&gt; ConVar::mRegisteredVars;
</code></pre>

<p>The crash occurs inside of the ErrorIf on the find method. If I comment that line it crashes on the line where it inserts.</p>

<p>The constructor is called before main (static instance of the class)
Does anyone know what might be going on here?</p>
