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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Alias template argument deduction is enabled in SFINAE contexts in C++17 mode
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            diverges-from:msvc
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          frederick-vs-ja
      </td>
    </tr>
</table>

<pre>
    After #77890 (implementing [P1814R0](https://wg21.link/p1814r0)) and possibly #89358, Clang starts to report CTAD for alias template can be well-formed in immediate contexts even in C++17.

As a result, the following example starts to be rejected in C++17 mode since Clang 19. [Godbolt link](https://godbolt.org/z/nYnbs8nd9).
```C++
template <class T>
T quick_retval();

template <class, template<class> class Tmpl, class...Args>
constexpr bool CanCtadFromImpl = false;
template <template<class> class Tmpl, class...Args>
constexpr bool CanCtadFromImpl<
 decltype(static_cast<void>(Tmpl(::quick_retval<Args>()...))), Tmpl, Args...> = true;

template<template<class> class Tmpl, class...Args>
constexpr bool CanCtadFrom = CanCtadFromImpl<void, Tmpl, Args...>;

template <class T>
struct Foo {
  explicit Foo(T);
};

template <class T>
using AliasedFoo = Foo<T>;

static_assert(CanCtadFrom<Foo, int>);
static_assert(!CanCtadFrom<AliasedFoo, int>);
```

If I understand correctly, `CanCtadFrom<AliasedFoo, int>` should be `false` in C++17 and `true` in C++20 or later.

GCC and EDG seem to be consistent with Clang (i.e. making `CanCtadFrom<AliasedFoo, int>` `true` in C++17 mode), while MSVC makes `CanCtadFrom<AliasedFoo, int>` `false` in C++17 mode and `true` later.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TXjyyACRVq2dPBBkeNFDi2KblCgpwUljm1uKFElKSfpry9IafOxSbEtsIAAwxzyvXmPwxnpvT4NRDsorqHYr-QUztbtjo4UOd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