https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106614
Bug ID: 106614 Summary: GCC skips using copy constructor when creating object using direct initialization in A a({A{}}); Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlame646 at gmail dot com Target Milestone: --- The following program prints `0` instead of `1` with gcc. https://gcc.godbolt.org/z/WEz336E3r ``` #include <iostream> struct A { int v = 0; A() {} A(const A &) : v(1) {} }; int main() { A a({A{}}); std::cout << a.v; //this prints 0 in gcc instead of 1 } ``` The above program should print `0` as per dcl.init#17.6. The same program is discussed here: https://stackoverflow.com/q/73345030/12002570