title: Order between destruction of global object and atexit in C++
body: <p>I wonder that can sure order between destruction of global object and <code>atexit</code> in C++</p>
  
  <p>I have a global object and register <code>atexit</code> function like below:</p>
  
  <pre><code>static MyClass g_class;
  
  void onExit()
  {
      // do some destruction
  }
  
  int main()
  {
      atexit(onExit);
  
      return 0;
  }
  </code></pre>
  
  <p>I've found <code>onExit()</code> is invoked before <code>MyClass::~MyClass()</code> in Visual Studio 2012 and gcc4.7.2. Am I sure that <code>onExit</code> is always invoked before global object(like <code>g_class</code>) destruction?</p>
  
  <p>I wonder global object register order and <code>atexit</code> register order use same order table.
  Or there is no relation between global object order and <code>atexit</code> order?</p>
  
  <p>Edited : Sorry I wrote a mistake. I'm so confused while tidying example code. <code>onExit()</code> is invoked before ~MyClass().</p>