https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114945
Bug ID: 114945 Summary: Sporadic std::vector::resize() -Wstringop-overflow or -Warray-bounds warning with gcc 14 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nilsgladitz at gmail dot com Target Milestone: --- Created attachment 58103 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58103&action=edit Testcase Initially seen with a Ubuntu specific GCC 14 x86-64 snapshot but also reproduced with a vanilla arm32 build of GCC 14.1-rc1. Not seen with GCC 13.1. I see there are a couple of issues which sound similar or related (e.g. bugs 113664, 106185, 105823, 105746) but I can't really tell if this is a duplicate or regression of a previously fixed issue. The reduced attached test case compiled with g++-14 -std=c++20 -O2 case1.cpp Produces the warning: /usr/include/c++/14/bits/stl_algobase.h:972:25: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 3 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 972 | __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adding -Wall replaces the above warning with this new warning: /usr/include/c++/14/bits/stl_algobase.h:972:25: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ offset [0, 2] is out of the bounds [0, 0] [-Warray-bounds=] 972 | __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Also recreated this on godbolt: https://godbolt.org/z/rYx9q7Ke1