<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/103477>103477</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang ignores visibility of a template method of a template class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
MaskRay,
rjmccall,
erichkeane
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
igorkudrin
</td>
</tr>
</table>
<pre>
For the following source `clang` generates the symbol `_ZN1tIcE3barILi1EEEvv` with the `DEFAULT` visibility:
```cpp
template <class a>
struct t {
template <int>
static __attribute__((__visibility__("hidden")))
void bar() {}
};
void test() {
t<char>::bar<1>();
}
```
```
> clang -c test.cpp -target x86_64 -o test.o
> readelf -sW test.o
...
5: 0000000000000000 6 FUNC WEAK DEFAULT 5 _ZN1tIcE3barILi1EEEvv
```
`gcc` for the same case generates a `HIDDEN` symbol: https://godbolt.org/z/9z7soKfoa
The problem may be similar to #31462, but there are no explicit instantiations with different visibility attributes here. Applying [D153835](https://reviews.llvm.org/D153835) or [D154774](https://reviews.llvm.org/D154774) fixes this issue, but these revisions seem to be abandoned. #72092 does not resolve it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGO2zgM_RrlQsSwJTuODz5kJgm2aLeHRYsCewlkmbbVypYhMZlJv34h25OkgzlsICQR-UjxUU-U3ut2QCxZ9sQ4_1v6X__IK-Oc8WfGufvZKyWNuRnQadX9QjlgMGX7lTxTZ12pW-t-nWunh1Vl62t5tA6oQ2isMfZFDy14e3YKgW1iZeTQsk0MLQ7oJKGfoP7aV9YEwOnfrwl9UgdRSffpi04Oh8PlEgJeNHUTlm3i_eG4-_7lWzBftNeVNpquTOxYvGfxjm3iealxnC2E_WgkITDxrIz0HiQTh9nnyZ0VAQHLn2YLAMBjhB7ohg4-T5K0gtNJEjldnQlPJ8a3jG9Pp3s5i413uq5xmJpYLOuW6WJ1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