<div dir="ltr">Proposed patch with more test cases: <a href="http://reviews.llvm.org/D13419">http://reviews.llvm.org/D13419</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 3, 2015 at 7:08 PM, Keno Fischer <span dir="ltr"><<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi folks,</div><div><br></div><div>I've been looking at explicit template instantiations lately, and came across the following</div><div>corner case where gcc and clang disagree on the visibility of a symbol. I'm inclined to think gcc's behavior is correct, but I wanted to make sure I'm not missing some reason why AddS needs to be visible.</div><div><br></div><div>Consider the following file (test.cpp):</div><div><br></div><div><div>template < typename T > class foo {</div><div>public:</div><div>    T x;</div><div>    T getX() { return x; }</div><div>    template < typename S ></div><div>    __attribute__ ((visibility("hidden"))) S AddS(S);</div><div>};</div><div><br></div><div>__attribute__ ((visibility("hidden"))) S foo<T>::AddS(S y) {</div><div>    return ((S) x) + y;</div><div>}</div><div><br></div><div>template < typename T, typename S ></div><div>__attribute__ ((visibility("hidden"))) S AddTS(T x, S y) {</div><div>    return ((S) x) + y;</div><div>}</div><div><br></div><div>extern template struct foo<int>;</div><div>template struct foo<int>;</div><div><br></div><div>int footest() {</div><div>    auto var = foo<int>{5};</div><div>    auto bar = var.AddS((long long)3);</div><div>    auto bar2 = AddTS((int)5,(long long)3);</div><div>    return var.getX();</div><div>}</div></div><div><br></div><div><br></div><div>$ gcc -std=c++11 -c -S -o - test.cpp | grep .hidden</div><div><span style="white-space:pre-wrap">       </span>.hidden<span style="white-space:pre-wrap"> </span>_ZN3fooIiE4AddSIxEET_S2_</div><div><span style="white-space:pre-wrap"> </span>.hidden<span style="white-space:pre-wrap"> </span>_Z5AddTSIixET0_T_S0_</div><div>$ clang-3.5 -std=c++11 -c -S -o - test.cpp | grep .hidden</div><div><span style="white-space:pre-wrap">     </span>.hidden<span style="white-space:pre-wrap"> </span>_Z5AddTSIixET0_T_S0_</div></div>
</blockquote></div><br></div>