Bug 123912 - [16 Regression] False positive -Warray-bounds -O2 in shared_ptr deleter
Summary: [16 Regression] False positive -Warray-bounds -O2 in shared_ptr deleter
Status: RESOLVED DUPLICATE of bug 122197
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 16.0
: P3 normal
Target Milestone: 16.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Warray-bounds
  Show dependency treegraph
 
Reported: 2026-02-01 16:38 UTC by maic
Modified: 2026-02-01 19:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 15.2.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maic 2026-02-01 16:38:12 UTC
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();
      |       ^~~~~~~~~
Comment 1 Drea Pinski 2026-02-01 19:44:56 UTC
Yes it is a dup of bug 122197.

*** This bug has been marked as a duplicate of bug 122197 ***