title: Is it legal to initialize a thread_local variable in the destructor of a global variable?
body: <p>This program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct Foo {
      Foo() {
          std::cout &lt;&lt; "Foo()\n";
      }
  
      ~Foo() {
          std::cout &lt;&lt; "~Foo()\n";
      }
  };
  
  struct Bar {
      Bar() {
          std::cout &lt;&lt; "Bar()\n";
      }
  
      ~Bar() {
          std::cout &lt;&lt; "~Bar()\n";
          thread_local Foo foo;
      }
  };
  
  Bar bar;
  
  int main() {
      return 0;
  }
  </code></pre>
  
  <p>Prints</p>
  
  <pre><code>Bar()
  ~Bar()
  Foo()
  </code></pre>
  
  <p>for me (GCC 6.1, Linux, x86-64).  ~Foo() is never called.  Is that the expected behaviour?</p>