https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118523
Bug ID: 118523
Summary: [15 regression] std::vector C++20 Wuninitialized false
positive
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gnu.ojxq8 at dralias dot com
Target Milestone: ---
This only happens in C++20 when nesting structs, one of which contains a
std::vector.
Reduced code:
#include <vector>
struct S {
std::vector<short> a{};
bool b{};
};
struct B2 {
B2(S = {});
};
struct E : public B2 {
E(S opts = {}) : B2{opts} {}
};
void fun() { E{}; }
Warning:
/opt/compiler-explorer/gcc-trunk-20250116/include/c++/15.0.1/bits/stl_vector.h:1118:41:
warning: '<unnamed>.S::a.std::vector<short int>::std::_Vector_base<short int,
std::allocator<short int> >.std::_Vector_base<short int, std::allocator<short
int> >::_M_impl.std::_Vector_base<short int, std::allocator<short int>
>::_Vector_impl::std::_Vector_base<short int, std::allocator<short int>
>::_Vector_impl_data.std::_Vector_base<short int, std::allocator<short int>
>::_Vector_impl_data::_M_finish' is used uninitialized [-Wuninitialized]
Godbolt:
https://godbolt.org/z/qGPMof736