https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90390
Bug ID: 90390 Summary: incorrect list initialization behavior for references Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: boehm-gc Assignee: unassigned at gcc dot gnu.org Reporter: mikedlui+gccbugzilla at gmail dot com Target Milestone: --- https://stackoverflow.com/a/54120116/1371191 Example from the link: int g_i = 10; struct S { operator int&(){ return g_i; } }; int main() { S s; int& iref1 = s; // implicit conversion int& iref2 = {s}; // clang++ error, g++ compiles fine: // `s` is converted // to a temporary int and binds with // lvalue reference int&& iref3 = {s}; // clang++ compiles, g++ error: // cannot bind rvalue reference // to lvalue } Because `s` of type `S` is not reference-related to `int`, a temporary of type `int` should be created during list initialization. Instead, it seems that the user-defined conversion occurs first.