<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130260>130260</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] missing an RVO opportunity
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ByunghoonKim
</td>
</tr>
</table>
<pre>
I just read a new Raymond Chen's article, [How can I choose a different C++ constructor at runtime?](https://devblogs.microsoft.com/oldnewthing/20250306-00/?p=110942), and tested it. It seems `clang` does not recognize the pattern described in the article, while both `gcc` and `MSVC` perform RVO.
Compiler Explorer [link](https://compiler-explorer.com/z/nEo4rTobY)
Can you verify if this is a bug or not?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxskk-L2zoUxT-NvLkkKPK_eOHFJBnzhsfjwbQMdClL17amsq6R5KSZT1-UMbSFrozRvUfn_HRkCGZ0iC0rT6y8ZHKNE_n2dF_dOBG5f82c9aTv7Qu8ryGCR6lBgsMbvMr7TE7DeULHRB1A-miURSbOwMrTP3QDJR28gJqIAoIEbYYBPboIZyZOTJxAkQvRryqSBxnBry6aGVnesfLCxHGKcQksf2KiY6LTeO0tjWE_G-Up0BD3imYmOrLa4S1Oxo1MdIKLkue82nGe9vJuYfnlcOBNIZhokjvpNEQMETWYuIeXCAFxDsAqrqx0I6s4aMIAjlJiRaMzHwhxQlhkjOgdaAzKmz4puMfBb-Fvk7EIPcUpKY5KJb10J6v4f1_ezul3QT-Qn-H17f8940-MP51pXoxFD88_FksefYJojfv-NxRqG97hNryR-GCic89U-K_Uf0tpP6WlgzutcEVvhjuYAeJkApgAEvp1BPIpKcu7TLe5bvJGZtge6uKQ57Xgx2xqVaNQl6Ipaiz7odaHGvlxOJZ93Vd5rZvMtBv2mh-Lqqj3QlVlrmWtenk45rxnBcdZGru39jrvyY-ZCWHF9pBzUfHMyh5teLRQiM9HECIV0rdpYdevY2AFtybE8Esimmgf1d02UqdYeYHZhGDcCNIlwEDLQj6uzsR7tnrb_slyNHFa-w1gkt4-u8XTO6rIRPewGpjoNrfXVvwMAAD__9VHB7Q">