title: Lambda capture, initializers and nested struct
body: <p>Could someone explain what is happening here (GCC 7.3):</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  struct A
  {
      struct B {};
  };
  
  int main()
  {
      int var = 0;
      std::thread([c=A::B(), var](){ });     // error: ‘var’ was not declared in this scope
      std::thread([c=A(), var](){ });        // OK
      std::thread([c=A::B(), var=var](){ }); // OK
      return 0;
  }
  </code></pre>
  
  <p>When I capture nested struct I got:</p>
  
  <blockquote>
    <p>'var' was not declared in this scope</p>
  </blockquote>
  
  <p>On the other hand, capturing non-nested struct works. Also capturing with initialization works. Also all cases work in Visual Studio.</p>