<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111216>111216</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Deduction guide fails for CTAD for template aliases
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
agraham-roku
</td>
</tr>
</table>
<pre>
Here's a case where CTAD for template aliases feature isn't working. Minimal code is copied below, but here also are godbolt links:
* https://godbolt.org/z/6jdo4qGG9 clang-trunk doesn't work
* https://godbolt.org/z/3KoG4PfWT GCC supports this, as far back as 12.1
```
#include <chrono>
template <typename Rep, typename Period>
struct duration {
constexpr duration(Rep r) : v{r} {}
template <typename R2, typename P2>
constexpr duration(duration<R2, P2> const& d)
: v{std::chrono::duration_cast<decltype(v)>(d.v)} {}
std::chrono::duration<Rep, Period> v;
};
template <typename Rep, typename Period = std::ratio<1>>
using seconds = duration<Rep, Period>;
template <typename Rep> using milliseconds =
seconds<Rep, std::chrono::milliseconds::period>;
template <typename Rep, typename Period, typename Period2>
duration(duration<Rep, Period>) -> duration<Rep, Period2>;
constexpr auto d1 = seconds{1};
constexpr auto d2 = milliseconds{d1};
static_assert(d2.v.count() == 1000);
int main() {}
```
The clang error is:
```
<source>:21:1: error: deduction guide template contains a template parameter that cannot be deduced
21 | duration(duration<Rep, Period>) -> duration<Rep, Period2>;
| ^
<source>:20:51: note: non-deducible template parameter 'Period2'
20 | template <typename Rep, typename Period, typename Period2>
| ^
1 error generated.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVl-P4jYQ_zTmZbQoGQOBhzywYdlKVaXTaaU-nhx7AN86dmo7bK-fvnIS_izHnu7UIiCOPfOb3_zx2CIEvbdEJZs_svlmIrp4cL4Uey8Oonnw7rWb1E59K38jTwyLAAKkCARvB_IE1ct6AzvnIVLTGhEJhNEiUIAdidh5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