[Bug libstdc++/90389] New: std::deque::emplace tries to call wrong overload internally
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90389 Bug ID: 90389 Summary: std::deque::emplace tries to call wrong overload internally Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: mikedlui+gccbugzilla at gmail dot com Target Milestone: --- Example: #include #include struct Foo {}; struct Bar { Bar(Foo f1, Foo f2, size_t c) {} }; int main() { std::deque deq; deq.emplace(deq.cbegin(), Foo{}, Foo{}, size_t{}); } https://godbolt.org/z/Bqw5Qv It looks like when instantiating `std::deque::emplace`, an incorrect overload to: template template void deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, size_type __n); is chosen instead of the expected: template typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, _Args&&... __args);
[Bug boehm-gc/90390] New: incorrect list initialization behavior for references
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.
[Bug c++/90391] New: nonconforming value initialization when type T has a base class with a user-defined default constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90391 Bug ID: 90391 Summary: nonconforming value initialization when type T has a base class with a user-defined default constructor Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mikedlui+gccbugzilla at gmail dot com Target Milestone: --- This is probably a low priority due to its edge-case nature, but here it is: https://stackoverflow.com/q/54028846/1371191 #include struct A { A(){} int i; }; struct B : public A { int j; }; int main() { B b = {}; std::cout << b.i << b.j << std::endl; } Compiling: $ g++ -std=c++11 -Wuninitialized -O2 a.cpp a.cpp: In function ‘int main()’: a.cpp:25:25: warning: ‘b.B::.A::i’ is used uninitialized in this function [-Wuninitialized] std::cout << b.i << " " << b.j << std::endl `b.B::.A::i` should be zero initialized (along with all of `b`) for C++11, but it looks like it's getting initialized by A's default constructor instead. This is the case for both C++11 and C++14. As others mention in the stack overflow responses, this behavior is expected in only expected in C++17/C++20, but for different reasons.