title: Static destruction of local-static object
body: <p>Help me understand this... see bold.  From the Standard 3.6.3 Termination (2)</p>
  
  <blockquote>
    <p>2 If a function contains a block-scope object of static or thread
    storage duration that has been destroyed and the function is called
    during the destruction of an object with static or thread storage
    duration, the program has <strong>undeﬁned behavior if the ﬂow of control
    passes through the deﬁnition of the previously destroyed blockscope
    object</strong>. Likewise, the behavior is undeﬁned if the block-scope object
    is used indirectly (i.e., through a pointer) after its destruction.</p>
  </blockquote>
  
  <pre><code>Manager&amp; GetManager()
  {
      static Manager localMan;
      return localMan;
  }
  </code></pre>
  
  <p>Then somewhere else...</p>
  
  <pre><code>{
     static User localUser;
     localUser.DoSomething(); //localUser calls GetManager and uses the reference returned.
  }
  </code></pre>
  
  <p>Then in the User destructor...</p>
  
  <pre><code>User::~User()
  {
     GetManager().DoSomethingOneLastTime();
  }
  
  //Now lets say Main exits and static destruction begins.
  //Somehow localMan is destructed before User.
  //Then user calls the GetManager() function in it's destructor.
  //What case is this defined, and what case makes this undefined?
  </code></pre>
  
  <p>Is the standard saying that if the local static localMan object that was statically created with the odr-use rule was destructed, and then the function was called again (creating a new static or not) this is undefined? It looks like it leaves room for there is defined behavior, but if it passes through the definition of the destructed object it is not.</p>
  
  <p>Anyone have clear insight on this?</p>