https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111273
--- Comment #2 from J Grossman <jgrossma at qti dot qualcomm.com> --- @Jonathan whether it's a warning or an error, it's incorrect. I'm filling a 1 element array with 1 element and it's saying it's out of bounds. That's a bug. I would like to use -Warray-bounds to catch coding mistakes, but to do that it needs to be reliable. Whether it's a warning or an error, if if there are false-positives, I have no choice but to turn it off. (And it's not like Wmaybe-uninitialized where if there is a false-positive, there's an easy workaround. If Warray-bounds has a false-positive, what can I do?) I've disabled -Warray-bounds to move forward, but that means some illegal operations that GCC could catch for us are going to go uncaught. If a warning option like this isn't reliable, people can't use it. BTW, if you disable Warray-bounds and add Wstringop-overflow, you get this for the same code: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 5 and 9223372036854775807 bytes into a region of size 4 overflows the destination [-Werror=stringop-overflow=] 437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); https://godbolt.org/z/T5W95hahx So I need to disable both. Once again, the code path here through `std::copy_n` is *incorrect*. It is in the "length > 1" section of memcpy, but I'm only moving 1 element, and in fact, when I set the size to 2, the warning/error disappears. Things that eliminate the error: - Using O2 instead of O3 - Using regular STL containers instead of GLIBCXX_DEBUG containers - Using size > 1 for the array - GCC 12, though I see similar spurious errors in GCC 12 as well, but not on this exact code