<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121208>121208</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Incomplete treatement for non-deduced context with nested template
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
frederick-vs-ja
</td>
</tr>
</table>
<pre>
Currently, Clang doesn't accept the following code snippet, while other implementations do ([demo](https://godbolt.org/z/Yccjc95Eb)).
```C++
template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f(cp, 0);
}
```
When `0` is replaced with `{}` (but not `nullptr` or any real null pointer constant), Clang also accept it ([demo](https://godbolt.org/z/19P6MK15P)).
The following similar example is rejected by all implemenations ([demo](https://godbolt.org/z/5oej5ohGT)), and shows that Clang also considers that `T` is not deducible from `B<T::template Nested>*` (and thus `B<T::template Nested>*` forms non-deduced context for `T`). Although the current standard wording is possibly defective on this (see cplusplus/CWG#660).
```C++
template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f({}, bcnp);
}
```
Given that `T` is (or should be considered) in the non-deduced context in `B<T::template Nested>*`, Clang should not try to match `B<T::template Nested>*` against `int` (or `std::nullptr_t`), and should just take `0` (or `nullptr`) as null pointer constant instead.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVk1v4zYQ_TX0ZRBDpiJbOuhgy_GiKFrswcCip4IiRxazFCmQI2fdX19Qku2kTbdZoMcCCmJw9ObzzaNECPpkEUuW7Vi2X4iBWufLxqNCr-XXh3N4eBaL2qlLWQ3eoyVzYbyCygh7AuUwWMY3BEJK7AmoRWicMe5F2xNIpxCC1X2PFEEvrTYIjlr0o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