<div dir="ltr">r99443 for PR6677 added this test (now in test/CodeGenCXX/template-instantiation.cpp):<div><br></div><div>// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = unnamed_addr constant<br></div><div><br></div><div><div>
namespace test0 {</div><div>  struct  basic_streambuf   {</div><div>    virtual       ~basic_streambuf();</div><div>  };</div><div>  template<typename _CharT ></div><div>  struct stdio_sync_filebuf : public basic_streambuf {</div>
<div>    virtual void      xsgetn();</div><div>  };</div><div><br></div><div>  // This specialization should cause the vtable to be emitted, even with</div><div>  // the following extern template declaration.</div><div>  template<> void stdio_sync_filebuf<wchar_t>::xsgetn()  {</div>
<div>  }</div><div>  extern template class stdio_sync_filebuf<wchar_t>;</div><div>}</div></div><div><br></div><div>This looks bogus to me. Per computeKeyFunction:</div><div><div><br></div><div>  // Template instantiations don't have key functions,see Itanium C++ ABI 5.2.6.</div>
</div><div><br></div><div>... and indeed 5.2.6 in the ABI says we emit the vtable in every TU.</div><div><br></div><div>Especially troubling is that if you remove the explicit instantiation declaration, we no longer emit the vtable, so if this *is* necessary for some reason, we're not doing it right.</div>
<div><br></div><div>So... I think this was originally incorrect, and still works only due to a bug. The attached patch fixes the glitch, but I wanted to make sure I'm not missing some subtlety here before going ahead with this.</div>
</div>