https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123912

            Bug ID: 123912
           Summary: [16 Regression] False positive -Warray-bounds -O2 in
                    shared_ptr deleter
           Product: gcc
           Version: 16.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: ---

Code to reproduce:

#include <memory>
#include <condition_variable>
struct a { };
void b() {
    std::shared_ptr<a>{nullptr, [](a*) {}};
}


Command to reproduce:

g++-16 -std=c++11 -Wall -Wextra -Warray-bounds -o /tmp/a.o -c /tmp/a.cpp -O2

godbolt:

https://godbolt.org/z/EM5Trbes6

Output:

/cefs/b6/b6a171e3e22b9ae35ef1d360_gcc-trunk-20260201/include/c++/16.0.1/bits/stl_construct.h:166:7:
warning: array subscript 'std::mutex[0]' is partly outside array bounds of
'unsigned char [24]' [-Warray-bounds=]
  166 |       __pointer->~_Tp();
      |       ^~~~~~~~~

Reply via email to