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

    <tr>
        <th>Summary</th>
        <td>
            Unintuitive behavior for deduction guides for constrained template classes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Given a template class whose class type is constrained by a concept, if the deduction guide is written without that same constraint it will never be selected because it is always less specific. I suggest that this behavior is subtle and unexpected and should produce a warning.

Sample code:
```cpp
template <typename T>
concept C = true;

void foo() noexcept;
void bar() noexcept;

template <C T>
struct S {
    S() noexcept = default;
    S(const S&) noexcept { foo(); }
    S(const T&) noexcept { bar(); }
};

// Deduction guide with unexpected behavior
template <typename T>
S(S<T>) -> S<S<T>>;

// // Deduction guide with expected behavior
// template <C T>
// S(S<T>) -> S<S<T>>;
```
https://godbolt.org/z/T79f164nW
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVEtz2yAQ_jXoshOPHpYdH3Ro7LbTs9PpGcRKIoNBI8CO--u7yFb8SNJpNSDY98fugrDyWH1XezTAweOu19wj1Jo7B4fOumnvjz2CclBb4_zAlUEJ4kg2xKix9yxfg2rAdwgSZai9sgbaoORodRiU9xTioHxngyc17sHxHV78eVCe5FqDwT0OIBAcaqx9DIQ1DwSFNMgZ1wd-dKCRYLkea9WoegY_wIW2RXd27jvSFNjxvbJDtHJBeI3AjYRg8LU_eY6kI0haQj9Ywk0acOCDUaadsXTD0i-n_5ZTaiJciaw489giPY2670-ctwSyYh0zZuIRn1nx9SQ-5wrWJN-AHwL5erqOsrdKQmMtyx9ZvgJj8XVM7qQ1ygUfPpO_R7G-Ck-JpsLAFtjyrA_0be-cjdgkNjzoi-NJcSxX3C1uTZZPF9hkRIzNR4bPHxm-nefGMG5uj8XybzRgc9desaeuSzoV_Z8qEqFtSTRyCNgDrRAZb8w4PoLxNzSfYDmbfFaes_j_IE0teCI773sX-3N01VoprPYzO7RE_ab5vFw12WJufiWyKuSqWPHEK7oW1U9qeB-Up4fgcmsamneX2Y3M60fg9s1Al4RBV3c4KCdBzGq7I0Lr_bQ80JV7oUQRqZwL6GhTzossTbqKL8u0RBTlPK-zIl80efbY8HyeLWRT5LhMNBeoXcXKJ1ZuElXlaZ6nRbrKHsusXM5WmM9FiqnghSj4omDzFHdc6VkMHDOSDNWIQYTWkVAr591FSEdRrUGc_PNAD9dQvbS2R52MaKsR6h_mEJ5t">