<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/129077>129077</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [rejects valid] CTAD failing for alias template
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ericniebler
      </td>
    </tr>
</table>

<pre>
    i believe (and a few folks in CWG agree) that the following code should compile. GCC trunk accepts it.

```c++
using size_t = decltype(sizeof(0));

struct index_type
{
  size_t value{~0ull};
  index_type() = default;
  constexpr index_type(size_t i) noexcept : value(i) {}
};

template <index_type... Extents>
struct extents
{
  constexpr extents(decltype(Extents)...) noexcept {}
};

template <class... Extents>
extents(Extents...) -> extents<(requires { Extents::value; } ? Extents{} : ~0ull)...>;

template <index_type... Index>
using index = extents<Index...>;

int main()
{
 extents i{0,0};
  auto j = extents<64,{}>({}, 42);

  index k{0,0};
 auto l = index<64,{}>({}, 42);
}
```

<details>

<summary>Diagnostic:</summary>

```
<source>:27:9: error: no viable constructor or deduction guide for deduction of template arguments of 'index'
   27 |   index k{0,0};
      | ^
<source>:20:1: note: candidate template ignored: substitution failure: deduced incomplete pack <(no value), (no value)> for template parameter 'Extents'
   10 | template <index_type... Extents>
      | ~~~~~~~
   11 | struct extents
   12 | {
   13 |   constexpr extents(decltype(Extents)...) noexcept {}
   14 | };
   15 | 
   16 | template <class... Extents>
   17 | extents(Extents...) -> extents<(requires { Extents::value; } ? Extents{} : ~0ull)...>;
   18 | 
   19 | template <index_type... Index>
   20 | using index = extents<Index...>;
      | ^
<source>:20:1: note: implicit deduction guide declared as 'template <index_type ...Extents> requires __is_deducible(index, extents<Extents...>) index(decltype(Extents) ...) -> extents<Extents...>'
<source>:20:1: note: candidate function template not viable: requires 1 argument, but 2 were provided
   11 | struct extents
      |        ~~~~~~~
   12 | {
   13 | constexpr extents(decltype(Extents)...) noexcept {}
   14 | };
   15 | 
 16 | template <class... Extents>
   17 | extents(Extents...) -> extents<(requires { Extents::value; } ? Extents{} : ~0ull)...>;
   18 | 
 19 | template <index_type... Index>
   20 | using index = extents<Index...>;
      | ^
<source>:20:1: note: implicit deduction guide declared as 'template <index_type ...Extents> requires __is_deducible(index, extents<Extents...>) index(extents<Extents...>) -> extents<Extents...>'
<source>:20:1: note: candidate template ignored: constraints not satisfied
<source>:20:1: note: cannot deduce template arguments for 'index' from 'extents<(requires { Extents::value; } ? Extents{} : ~0ULL)...>'
<source>:20:1: note: implicit deduction guide declared as 'template <> requires __is_deducible(index, extents<(requires { Extents::value; } ? Extents{} : ~0ULL)...>) index(Extents ...) -> extents<(requires { Extents::value; } ? Extents{} : ~0ULL)...>'
```

</details>

See https://godbolt.org/z/qxsTWGsdx

Christof Meerwald (@cmeerw) of CWG explains it thusly:

> You try to deduce `extents<(requires { Extents::value; } ? Extents{} : ~0ull)...>` from `extents<Index...>` (but can't deduce anything). As you didn't deduce anything, substituting into the original deduction guide doesn't change anything. So your `f'` is the same as `f` (and as you haven't deduced anything, you only use the template parameters from the original deduction guide, but none from the alias template). After doing deduction for `f'`, the only thing left to do is the deducible check (which also succeeds).

this issue seems distinct from #111216.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWE1v2zwS_jX0ZVBBomzLPvjg-KNYoHtqF8WeAloaWWwo0iWpJO6hv30xpGw5cdomu-0uFngNAbbJ4TPPfJKUcE7uNeKCTW7YZD0SnW-MXaCVpZa4U2hHO1MdFxJ2qCTeIzA-E7oCATU-QG3UnQOpYfX5PYi9RWR8Dr4RHnyDNK3Mg9R7KE2F4BrTqQpK0x6kwgTer1bgbafvQJQlHrwD6ROWLumZpvEpGb-hJ112joCc_Ia3Hli-hgpL5Y8HZHxGo6ZmfJYyPqcnv4k4ztuu9CB1hY-3QThdsoIm4QR1L1SHrLj5nnZKsWId18LlGj4js6LOWnTKn2RKo53H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