https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125743
Bug ID: 125743
Summary: -Warray-bounds false positive in bit7z involving
std::vector and CMyComPtr
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Hemanth.KumarMD at windriver dot com
Target Milestone: ---
GCC 16.1.0 reports multiple -Warray-bounds diagnostics when compiling
bit7z 4.0.12.
The warnings originate from libstdc++ internals such as
bits/stl_vector.h and bits/basic_string.h after aggressive inlining
through bit7z COM-style smart pointer wrappers (CMyComPtr), make_com(),
and std::vector destruction paths.
Representative diagnostics:
error: array subscript 3 is outside array bounds of 'void [24]'
error: array subscript 3 is outside array bounds of 'void [32]'
error: array subscript 0 is outside array bounds of 'void [24]'
The warnings are triggered from code paths involving:
return CMyComPtr<I>(new T(std::forward<Args>(args)...));
and later propagate through:
std::vector<CMyComPtr<bit7z::CVolumeOutStream>>
bit7z::CMultiVolumeOutStream::~CMultiVolumeOutStream()
bit7z::BitOutputArchive::compressTo()
The diagnostics ultimately point into libstdc++ headers such as:
bits/stl_vector.h
bits/basic_string.h
The issue is reproducible from the attached preprocessed source file.
Compilation command used for reproduction:
x86_64-oe-linux-g++ -O2 -std=gnu++14 -Warray-bounds -Werror \
-c bitoutputarchive.cpp.ii
The warning appears to be a false positive resulting from object-size
tracking and aggressive inlining.
Possibly related to PR56456 (-Warray-bounds meta-bug).