<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Visibility attribute ignored on static data member explicit instantiation"
href="https://bugs.llvm.org/show_bug.cgi?id=39118">39118</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Visibility attribute ignored on static data member explicit instantiation
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ldionne@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Visibility attributes applied to explicit instantiations of non-static data
members appear to be ignored by Clang. In the following example, I apply hidden
visibility to everything in the namespace, but I explicitly instantiate
Bar<int>::foo with default visibility. The expected behavior is that
Bar<int>::foo is given default visibility, but the actual behavior is that is
has hidden visibility.
-----------------------------------------------------------
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
#define HIDDEN __attribute__((__visibility__("hidden")))
#define VISIBLE __attribute__((__visibility__("default")))
namespace ns HIDDEN {
struct Foo { };
template <typename T>
struct Bar {
static Foo foo;
};
template <typename T>
Foo Bar<T>::foo;
// CHECK: @_ZN2ns3BarIiE3fooE = weak_odr global
// CHECK-NOT: hidden
template VISIBLE Foo Bar<int>::foo;
}
-----------------------------------------------------------
This test case should work inside the llvm-lit test suite. It can also be run
as `clang++ t.cpp -shared | nm`, and then you can notice that `Bar<int>::foo`
is not exported from the generated executable:
0000000000001000 d __ZN2ns3BarIiE3fooE
U dyld_stub_binder</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>