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

    <tr>
        <th>Summary</th>
        <td>
            Access checks and copy elision before c++17
        </td>
    </tr>

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

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

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

<pre>
    We claim to support guaranteed copy elision in C++03, but we still perform access checks for copy constructors (before c++17)
https://godbolt.org/z/WPEh8e94c

```cpp
class S {
public:
S(int, int);

// private:
S(const S &amp;);
};

S s = S(0, 0);
```

If we make the constructor public, RVO is performed https://godbolt.org/z/WPEh8e94c


Aditionally `__cpp_guaranteed_copy_elision` is not set even if  the documentation claim it should be
https://clang.llvm.org/docs/LanguageExtensions.html#id34

Maybe the documentation is just wrong.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk0FvpDgQhX9NcSmlZQx0w4EDnaSllXa1q400ObaMKcCJsZFtOtPz60fuJumZzFxGsuQDVa8-6vkJ79VgiGoo9lA8JGIJo3W1tC4zQZmktd25fiaUWqgJg0W_zLN1AYdFOGECUYfSzmckrbyyBpXBe-B74HuWAb_Hdgn4RuiD0hpncr11EwopyXuUI8lXj711Vw1pjQ9ukcE6j8DLlnrrCOVVL90Br4A1Ywizh6wBfgB-GGzXWh021g3AD9-AH57_exxLqnIJrIlny65HzjOwRmrhPT4h7PbAmnlptZJRjDVPwEtlQoS-XBVk-1XiMglnp04i0K36whu1-FZMcyz_aNo9fHQ_oUfIHjB2sKjObmXvbNfKv_q4qkm8EoaRflwHrqD8Hv__8i8q_75K6vBP98GaplNBWSO0PiNs2fEo5_l4M_QYzTiuhsKWxXHGBvQUkE5kUPV4AeysXCYyQUS19YmogH60i-6wpV_MklqYYaP1aVr5Ois98MPfwgyLGOjxayATp_rNGCYNPFNdll-h_xHnln4zVnl8WXzAN2fNsAHWJF2ddVVWiYTqdFdUBcuqIk3GWrJtz7koeSdYTrIvqo52YreVZZpTT7tE1ZzxImUsSwtWFGxDqRBEuSz7nLGirSBnNAmlP34hUd4vVKfbtCzKRIuWtL9EiXNDb3j5CpzHZLk6Nt21y-AhZ1r54G8yQQVNdfNTLIT5FK3PcUgWp-tP7qswLu1G2gn4Iaqv193s7AvJAPxwYYpLX6FPNf8eAAD__7UuRU8">