[cfe-dev] Clang disagrees with gcc at the intersection of explicit template instantiations and visibility
Keno Fischer via cfe-dev
cfe-dev at lists.llvm.org
Sat Oct 3 20:09:50 PDT 2015
Proposed patch with more test cases: http://reviews.llvm.org/D13419
On Sat, Oct 3, 2015 at 7:08 PM, Keno Fischer <kfischer at college.harvard.edu>
wrote:
> Hi folks,
>
> I've been looking at explicit template instantiations lately, and came
> across the following
> 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.
>
> Consider the following file (test.cpp):
>
> template < typename T > class foo {
> public:
> T x;
> T getX() { return x; }
> template < typename S >
> __attribute__ ((visibility("hidden"))) S AddS(S);
> };
>
> __attribute__ ((visibility("hidden"))) S foo<T>::AddS(S y) {
> return ((S) x) + y;
> }
>
> template < typename T, typename S >
> __attribute__ ((visibility("hidden"))) S AddTS(T x, S y) {
> return ((S) x) + y;
> }
>
> extern template struct foo<int>;
> template struct foo<int>;
>
> int footest() {
> auto var = foo<int>{5};
> auto bar = var.AddS((long long)3);
> auto bar2 = AddTS((int)5,(long long)3);
> return var.getX();
> }
>
>
> $ gcc -std=c++11 -c -S -o - test.cpp | grep .hidden
> .hidden _ZN3fooIiE4AddSIxEET_S2_
> .hidden _Z5AddTSIixET0_T_S0_
> $ clang-3.5 -std=c++11 -c -S -o - test.cpp | grep .hidden
> .hidden _Z5AddTSIixET0_T_S0_
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151003/f8d003ce/attachment.html>
More information about the cfe-dev
mailing list