title: gcc and clang implicitly instantiate template arguments during operator overload resolution
body: <p>Consider this code:</p>
  
  <pre><code>struct A; // incomplete type
  
  template&lt;class T&gt;
  struct D { T d; };
  
  template &lt;class T&gt;
  struct B { int * p = nullptr; };
  
  int main() {
      B&lt;D&lt;A&gt;&gt; u, v;
      u = v;  // doesn't compile; complain that D&lt;A&gt;::d has incomplete type
      u.operator=(v); // compiles
  }
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/bee4448c4b33d91f">Demo</a>. Since <code>u.operator=(v)</code> compiles but <code>u = v;</code> doesn't, somewhere during the overload resolution for the latter expression the compiler must have implicitly instantiated <code>D&lt;A&gt;</code> - but I don't see why that instantiation is required. </p>
  
  <p>To make things more interesting, this code compiles:</p>
  
  <pre><code>struct A; // incomplete type
  
  template&lt;class T&gt;
  struct D; // undefined
  
  template &lt;class T&gt;
  struct B { int * p = nullptr; };
  
  int main() {
      B&lt;D&lt;A&gt;&gt; u, v;
      u = v;
      u.operator=(v);
  }
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/abdf8b03af21d782">Demo</a>.</p>
  
  <p>What's going on here? Why does <code>u = v;</code> cause the implicit instantiation of <code>D&lt;A&gt;</code> - a type that's nowhere used in the body of <code>B</code>'s definition - in the first case but not the second?</p>