https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118253
Bug ID: 118253 Summary: libstdc++: array subscript 0 is outside array bounds of ‘std::__shared_count<> [0]’ Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jengelh at inai dot de Target Milestone: --- Version: gcc version 15.0.0 20241230 (experimental) (SUSE Linux) amd64-linux Input: --- #include <memory> #include <unordered_set> struct R {}; using R_ptr = std::shared_ptr<R>; using listtype = std::unordered_set<R_ptr>; void newthing(listtype &L) { R_ptr r; r = std::make_shared<R>(); L.insert(r); } R_ptr getfirst(listtype &L) { if (L.begin() == L.end()) return nullptr; auto r = *L.begin(); return r; } void movething(listtype &L, R_ptr &&r) { L.insert(std::move(r)); } --- Output: $ g++ -fsanitize=address,undefined -O2 -c -Wall x.cpp /usr/include/c++/15/bits/shared_ptr_base.h:1099:19: warning: array subscript 0 is outside array bounds of ‘std::__shared_count<> [0]’ [-Warray-bounds=] 1099 | __r._M_pi = _M_pi; In function ‘void movething(listtype&, R_ptr&&)’: cc1plus: note: source object is likely at address zero Expected instead: Don't warn(?). This seems like normal code.