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

    <tr>
        <th>Summary</th>
        <td>
            clang misses pass by value optimization opportunity if using C++ default member initialization
        </td>
    </tr>

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

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

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

<pre>
    according to the output of clang trunk on godbolt https://godbolt.org/z/c1a8ooWfe

I feel that it misses some optimization chances by removing the copy entirely instead of creating the variable on the stack and then copy it, because the caller, never really modifies the **big_struct** object.

switching to C-style initialization (or turning off the default member initialization of the struct) seems to fix it.
as shown here:
https://godbolt.org/z/E7x1x7To8
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEUk1v4zYQ_TXUZRBDoqTYOujgJDXae4EeiyE1sqahSIEcOnF-fSHZxi5y2L1ImMEj3wcfpsRnT9Sr9kW1bwVmmULs_0QeKOKEfkDHhQnDtUdrQxzYn0ECyEQQsixZIIxgHa7rmP07BA_nMJjgBCaRJan6qPRJ6dN9uwvxrPTpS-mTrfAQwj8jqfJNlcfb9y8YiRzIhAIsMHNKlCCFmSAswjN_oXDwYCf0lhKYK0Saw2UTNhHYsFyBvHAkdwX2SQiHTWQklAfqgpHROFrlrnMStO-Aflgnf7uERelXMGQxJ7rdjc5RXLeeLhQhEjp3hTkMPDKlDaP0Uemj4fO_SWK2cpshmP_Iyu5np-mDxU73QF-fklwdAXsWRvdwqfQhRJAc_YoL47hxDDRidgIzzYbi9zNhvFu60XeQiOa0koz8CfwQgQnSFD48TBRpfaVt-7s3-2P_WX3u_w6HYujroas7LKivnvdd3TRV2xRTXzV00LVtD9Z0-2Yc91hWum3qgza0b60puNelrstal7rUXdXsGjM0uqm6YRh1p-tGNSXNyG7n3GVeuQtOKVP_XLVtVzg05NKjsLFfQU8mn5NqSsdJ0o9jwuKov7XzXqQF09aZC7r8rVFhWUKU7FmuwCPktEb-qvSL0i-_jrzI0fXfkmOZstnZMCt9WgXdf09LDGsTlD5tppLSp83X_wEAAP__1fYy4Q">