<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62053>62053</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Access controls checked incorrectly for member classes declared in templated subclasses
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
The following code compiles in GCC and MSVC, but not Clang:
```
#include <type_traits>
class Base {
protected:
Base(int i);
};
template <typename U>
class Derived : public Base {
public:
template <typename T, typename = void>
struct ConstructsBase : std::false_type {};
template <typename T>
struct ConstructsBase<
T, std::void_t<decltype(Base(std::declval<T>()))>>
: std::true_type {};
};
void foo() {
static_assert(!Derived<const int&>::ConstructsBase<const int>::value);
}
```
(See https://godbolt.org/z/nP795M9qc )
Apparently the template argument list for `ConstructsBase` is evaluated in a context with access to `Base`'s protected constructors, which seems slightly surprising, since `ConstructsBase` isn't itself a subclass of `Base`.
More surprisingly, if `Derived` is made a non-templated class, this works correctly.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE1v4zYQ_TX0ZRBDpixZPujgKOueAhTYba8BTY0lNhSpckZJ3V9fkPJXkw1WEPTF4bz35s1IEZnOIdaieBTF00JN3PtQj6-K2LhucfDtqf7RIxy9tf7duA60bxG0H0ZjkcA4-K1pQLkWnr__2QjZwGFicJ6hscp1It-J7ElkO1Fm53N-lblx2k4tgsgbPo34wkEZJpF_O0ekq7aKCB4VIYjN4_wNxuAZNWN7zQ4pRMjKOAYj5Fbk52Cxebo9pyvjMFrFV2CnBoQ_rrgz4hMG84YtiHwH43SwRn8ikb7eMfhp3h-xItc3kT_BmzftFQyAOEyaofFufqIZJt8BcdKX747KEr7EJAn-k6AvoX-BIvLmsh6PRPUKGmm-sMibFrWNOYWszjW-xsSlN2VF3iQsWcXCz2f-7Q49Hv9TxGH6QtAncZEHHL2fs9_VH4gVG_2iiDBwWl6dXRN5o6NSMI6FLBOZCPtJ_i3qEvKm7IQf--enDXxu4-o7IvTMI8UEci_kvvPtwVte-tAJuf9XyL37fbMtnrd_a4ip7_bvxlEFdGxPwD3efFShmwZ0DNYQw9EHEGX2gX6ZgSHAyFgxtnEUFWjvGP9heDfcg9IaiYB93H3eI-SGbgME-pLTB4r-v_dG90CIAwFZ0_WRGk1hDIaM61KLGKfxKz5OyA2DYUJ7BAU0HeZ58sc7Dsv7Ejz7gHcI9hQxTAq_2DkrHVSLoMB593CpUwspe5qx3hC8-_BKoH0IqNmelou2ztttvlULrFdltVptZLEuF32d6WKbt-WqWreqklvVltuqLJTcZGpzKLRemFpmMs_Wq1WWSSnL5brQm6rItiusKlVgJtYZDsrYpbVvQ7R6YYgmrEuZFfnCqgNaSn9VKR2-Q1oUUsafbKjjnofD1JFYZ9FhumVhwxbr3excdDN4S6B71K_J46u41BUDDgcMcxWQIA6kCnMv3Gp0MQFpMQVbf2hWw_10WGo_CLmPLM63hzH4v1CzkPvEnYTcJ23_BQAA___XputT">