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

    <tr>
        <th>Summary</th>
        <td>
            Constant expression evaluation misses copy elision
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20,
            clang:frontend,
            rejects-valid,
            consteval
      </td>
    </tr>

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

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

<pre>
    The following code fails to compile on Clang:
```
struct A {
    int i = 0;

    consteval A() {}
    consteval A(const A&) { i = 1; }
 consteval int f() { return i; }
};

int main() {
 static_assert(A{A{}}.f() == 1, "");
}
```
because we do not elide the copy constructor call. However, we do elide it at runtime: https://gcc.godbolt.org/z/P8xYjnYjM
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0UsGOnDAM_ZpwsXYEBgbmwIEZhHqp1EMve6oyiWGyCskoCbO7_foqgIZupUqR4th-fs-OufdqNEQNK8-s7BI-h5t1TcudNWeu9cRNcrXys_l5Ixis1vZdmRGElQQDV9pDsCDsdFeawBq4aG5Glrcs7VjasmO6neXpg5tFgBZYdV49AADKBFDA8g5Slm_-PSqs8YEeXEPLsGZ4WsBV97-M5RWt45a71c5YfoYdt4Mi_bCXBkdhdgbUl_xofNUWYRNX5i9Ra2UfeFDiF_eeXGBYt6w6t5vmqjs8qfJulYUXYIjLOe0cT-KvE7yS4LMneCeQFowNQFpJgnAjEPb-ufYVp2wdCK71Ab7Zd3qQizwrakWoADyAm01QE7G8hVsIdx9_DnuG_SjEYbTyanU4WDcy7H8z7H_UH69v5vXteyKbXJ7yE0-oyY5VcSzTGqvk1gzZUGcDciELmZf1wMtMyLqQoqLTUFYyUQ2mmKcZlhkWVVodBixSMWQkj1TkJQ6sSGniSh-0fkyRO1Hez9QcU6yPieZX0n7ZVkTB8MzwjOkyvUv0bOs3OGsCGfkMOHojEfzLg2u1e59bED1ll7gmkr5c59GzItXKB7_LCCpoai4Rwk0A-rg78l5ZA7HCzEM0J-U9-fUvSKsYTmanm3-mq8Jtvh6EnRj2kWC7Xu7ORp0M-6Vpz7Bf-v4TAAD__8BTFiY">