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

    <tr>
        <th>Summary</th>
        <td>
            Aggregate deduction broken in function templates
        </td>
    </tr>

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

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

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

<pre>
    The following snippet works on MSVC and GCC, but fails to compile `fnTemplate` under Clang -- https://godbolt.org/z/KvjTqarxa:

```cpp
struct Inner {
  // Clang works if you comment this
  Inner() = default;
};

template <typename T>
struct WantsCTAD {
  T t_;
};

auto fn() {
    WantsCTAD ok{.t_ = Inner{}};
    (void)ok;
}

template <typename>
void fnTemplate() {
 // error: no viable constructor or deduction guide for deduction of template arguments of 'WantsCTAD')
    WantsCTAD bad{.t_ = Inner{}};
 (void)bad;
}

int main() {
  fn();
  fnTemplate<int>();
  return 0;
}
```

I'm a bad language lawyer, so I can't say with confidence whether Clang or GCC/MSVC are out of compliance here, but ... it's surprising and inconsistent that this behavior is contingent on both of these:
 - asking for CTAD in a function template (rather than just function)
 - adding a user-declared ctor to `Inner` -- IIUC as of C++20 this makes `Inner` not an aggregate type

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVE2vqzYQ_TXOZpTIMQHCgkXCbaqrqqum7fLJ4An4BWxqj5Pe_vrKkI-bd1VVQkoE4_E5c84Z6b1uDWLJ0j1L3xYyUGdd6Y1050F6Qreorfoojx3Cyfa9vWrTgjd6HJHgat3ZgzXw629_VCCNgp-riokK6kBwkrr3QBYaO4y6R2AZP5kjDmMvCVnGIRiFDqpemhaWS-iIRs-SHRMHJg6tVbXtaWVdy8ThHyYOv1y-H_-S7m8Za_j0ZHx-mnFkfOfJhYbg3Rh0wPI94zuAudvtlhmwPsGHDRHXgIaAOu2n0ukgE1smCmDJGyg8yd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