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

    <tr>
        <th>Summary</th>
        <td>
            constexpr checking not considering copy elision
        </td>
    </tr>

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

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

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

<pre>
    ```cpp
#include <iostream>

struct Elem {
    unsigned short data;
    constexpr Elem(unsigned int a) noexcept : data(static_cast<unsigned short>(a)){};
    Elem(const Elem& elem) : data(elem.data) { std::cout<<"call copy constructor\n"; }; // error with clang -std=c++14, ok with gcc and msvc
    // constexpr Elem(const Elem& elem) : data(elem.data) {}; // ok
};

 constexpr Elem foo() noexcept {
    return Elem{0x0400};
}

int main() {
    Elem e1 = foo();
 std::cout<<e1.data<<std::endl;
}
```

Clang performs the copy elision for the return statement in foo(), but still reports error about the copy constructor.  I know copy elision is not guaranteed with pre-C++17, but since clang does perform it, there should not be a error.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2OszgQfBpzaU0ETTKEA4dJ8kXap1gZuxO8Y2xkN_Pz9isbvgnRfpeVrBDbuKq6q4yM0dwdUScOJ3G4FHLmwYdOfn9KK4ve6-9OvJbLUNMkyoso3wTWxik7awJRn42PHEiOov61buffyGFWDL8sjSCa07IIADC7TKkhDj4waMlS1Jt95V1k-ppCPivw-HPAOAYpsAXn6UvRxCDqtwUAj5ElG_W3kpFFfX4mSdLwmI6m0ZxEc3miXIky8zp5BcrPdsuRlnbL_zYVBZG1qN9E_ab8nGjTQFTSWlB--l5qSX3wQRzOTiCK-gQLPQi8CrwCheADfBoeQFnp7vCSUS9K4EngqdoLPIN_X964KwXSaRjjh3roX5H-07n_XdCzMv--Grpp10r6TAU37wUen63Zeh6I5-AWJc2p_Cr3ZfmE2ly28MnoURq3Yj5BZT6qQNSXB-3DzT84QtVSYp787JPT9g_8v8O-lXPOtkwUbj6MEXigxV2yJhrv4OZDXlyrTEmkkRyDcRuJeIZ-ZohsrIVAkw8cV_Nl72d-4G5SswP4C96d_3xmNBGcZ7jPMkjHRHpJxxTo5bzGpvkhNE7RGi3tKf4uBAynV3igQOmazFZn0J5ALrp2S_mF7mrd1q0sqKuaGsuqPOyxGDrd325SS3nDXslSvbatPrSStDrovj7otjAdlrivqqqtyhIRdwqJ9tTcqG9KQlmLfUmjNHZn7ce48-FemBhn6qrqtWmOhZU92Zi_TYiOPiHvplt0uBShS4de-vkexb60JnJ8wLBhS90jpWog9W7cPVeYlo2mkObbthZzsN3APMUUkXwH7oaHud8pPwq8JvT18TIF_w8pFnjNmqLA6yr6o8N_AwAA__9BXaHA">