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

    <tr>
        <th>Summary</th>
        <td>
            [clang][c++20] CTAD failue with deduction of returned object
        </td>
    </tr>

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

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

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

<pre>
    ## Description

The following code causes a clang compilation error, while it compiles fine with MSVC:

```cpp
template <typename T> struct Wrapper {
  T val;
};

template <typename T>
auto get_wrapper() -> Wrapper<T> {
  return Wrapper{0};
}

template <typename T>
auto get_wrapper_designated() -> Wrapper<T> {
  return Wrapper{.val = 0}; // <- this causes compilation error
}

auto main() -> int {
  auto wrapped = get_wrapper<int>(); // compiles fine on both msvc and clang
  auto wrapped_designated = get_wrapper_designated<int>(); // clang compilation error
  return 0;
}
```

## Expected

Deduction succeeds on returned object and program compiles.

## Context

Windows 11
clang version 19.1.3
Target: x86_64-pc-windows-msvc
Thread model: posix

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklM2OozgQx5_GXEpBYEggBw5J6FxWe9po-9gydgU8MhjZJkm__QhMuklPeg4zUhTA5fLvXx8uZq2sO8SCrPdkXQZscI02xT9MuZsMKi3eC0ITQhMo0XIjeyd1R6KSRDv_f2oQzlopfZVdDVwLBM4GixYYcMWmtbaXio2OgMZoQ-gBro1UCNLNVrRwlh3CVboG_v3v_wNJdksK2UT-x_verzhse8UcAkkO7r3HjrUIJ5K8gHVm4A5eDet7NECyvfcAOMGFKZLM3yQrP99_f6Y3s8FpqNG9Xf3RhOaEbmE1QmcaSQ6ThgXUoBtM97Eh20cP4Kz8CwVvAsfyMYfiD8WEF6aAJCXMqoDQI6HHkb8C10h7r-avVXymfxLYMtkt5cjOLTVMe3wAYkIvU5ocZOfGeCf_haDHPtEdVNo10NoLB9YJ32rPCIsUfYUts_c995sefkxo9KSg95Z96GN_l15uPfIRuzCVKAY-AezAOaKwY5T-fBSgqx_I3RRrb3RtWPuRkvAJ4aA7hze3tLzKTuirhTj23z6yCxo7QuNtGIfJfKeZqdGRZAe3fPO2SVc9X12992rM-P3mG2QCWi1QjXt7beXNmwJRJGKbbFmARZwlUbZOaZ4FTRHTKso2XMTpNhVZVtFNFdE8Peecxfkm44EsaETTOI5SGkdpmoVJXDGW51kWC0zPvCJphC2TKlTq0oba1IG0dsAijtM8iwLFKlT2Ps1MMe5aVUNtSRopaZ399HPSqWnu-d5Zl-MroXtC9zQi6xIOp10JZybVMA8m8VEiff5amWAwqmic6-04uqbeqaVrhirkuiX0OGLnx6o3enQh9Dhpt4QeZ_mXgv4MAAD__6z_saY">