<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72396>72396</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
discrepancy between clang and gcc regarding list initialization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yxsamliu
</td>
</tr>
</table>
<pre>
There is a discrepancy between clang and gcc regarding list initialization when there is only one element in the list:
`#include <stdio.h>
#include <initializer_list>
#include <utility>
class list {
public:
list() {
printf("default ctor\n");
}
list(std::initializer_list<list> elem ) {
printf("list ctor\n");
}
};
int main(int argc, char **argv) {
list mylist{list{}};
}`
In the above code, clang does not use the list ctor but gcc uses.
https://godbolt.org/z/17WaacKG3
https://godbolt.org/z/5nbEP14qv
Open this ticket to discuss which behavior is correct.
@zygoloid
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2P2zYQ_TXUZbAGRVKyddDBa6-Loof2UKDHgh9jiS1NuiTlrffXB6K9XjsJEgS5aAjOcN57wyfKlOzgEXvSPJNmW8kpjyH25_-TPDg7VSqYc__niBHBJpBgbNIRj9LrMyjMr4getJN-AOkNDFpDxEFGY_0AzqYM1ttspbNvMtvg4XVED_m9X_DuDMEjoMMD-rl6TpaThK8J3RL6_m0pYdx67SaDQPgmZWPDYiT85VrwkL3BYvz70u2rZVO2zubzLQuXoJ1M6cKfLJ8ve8dJOatvrC4c2Yqw7qMGAOAYrc_7kmEG93JyGXQOkTQbTxgjrCP8Vk6W2wfg964pmxmJr7_UsbnKKTODb8IXAd_Hnhe37UuwPsNBWk_Yal7KOGjCNqBHGYGwNWFrGYfTI_idAjicC8vl8zXMEHco87ql99f76-XipQonBB0MFrhiLBMwgQ8ZpoQ3dxRZoKZcPDclTIv7dmPOxzRPkO0I2w3BqODyIsSBsN0bYbt6-ZeU-rdf-I8carx6-aMW_53uD_1-LIa2CbLV_2KGHMpPMqUEr6PVIygc5cmGOBtehxhR5weuRNC38xBcsAYq03PT8U5W2NdLSmnT8ZWoxl4KirVY8WapWtEKIVuuWtEoqpq96lZtZXtGGa_ruqmF4FQs6GrPjeJK8I6ppuuIoHiQ1i2cOx1mVZVNacJ-yXjXVk4qdKm8AoyVuc9-abZV7Of6JzUNiQg6jz59dMg2O-x_8k2opuj6z2Zv8ziphQ4HwnYz2jU8HWP4B3UmbFfIJ8J2hf-nAAAA__8QJnYG">