[Bug libstdc++/115824] New: Strange -Warray-bounds warning when assigning an initializer list to a vector of pointers
mytbk920423 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 8 08:36:05 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824
Bug ID: 115824
Summary: Strange -Warray-bounds warning when assigning an
initializer list to a vector of pointers
Product: gcc
Version: 12.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: mytbk920423 at gmail dot com
Target Milestone: ---
The following code has a strange warning on GCC 12.4.0 when compiled with -O2
-Warray-bounds. (compiler explorer link: https://godbolt.org/z/sr56Yro6n)
#include <vector>
std::vector<int *> v;
void test(int a) {
int *p = new int(a);
v = {p};
}
stl_algobase.h:434:30: warning: 'void* __builtin_memcpy(void*, const void*,
long unsigned int)' forming offset 8 is out of the bounds [0, 8] of object
'<anonymous>' with type 'int* const [1]' [-Warray-bounds]
434 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In GCC release 12.3.0, 13.x, 14.x and trunk, there is no such warning. I think
it can be some problem in the libstdc++ change in 12.4.0 release.
More information about the Gcc-bugs
mailing list