<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 - Incorrect accessibility check when using decltype inside class definition"
href="https://bugs.llvm.org/show_bug.cgi?id=39169">39169</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect accessibility check when using decltype inside class definition
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>romain.geissler@amadeus.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hi,
The following snippet will current result in an error with all clang versions
(including trunk):
<<EOF
#include <type_traits>
class A
{
private:
static std::true_type F(int);
static std::false_type F(...);
public:
template <typename T> using F_t = decltype(F(std::declval<T>()));
static_assert(A::F_t<int>::value, ""); // OK
};
static_assert(A::F_t<int>::value, ""); // KO
EOF
The error happens on the second static_assert made outside the class
definition:
<source>:11:52: error: 'F' is a private member of 'A'
template <typename T> using F_t = decltype(F(std::declval<T>()));
^
<source>:16:18: note: in instantiation of template type alias 'F_t' requested
here
static_assert(A::F_t<int>::value, ""); // KO
^
<source>:6:31: note: declared private here
static std::true_type F(int);
^
1 error generated.
Compiler returned: 1
Given that the "decltype()" expression is used inside the class itself, I would
consider that it is OK to access private members from there, thus using the
public "F_t" from outside the class should be OK.
gcc compiles this without error.
Cheers,
Romain</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>