https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103176
--- Comment #3 from Josiah VanderZee <josiah_vanderzee at mediacombb dot net> --- Created attachment 51768 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51768&action=edit Test case to reproduce strange -Wstringop-overflow warning I'm worried this test case is too large to conveniently go through and investigate. I tried to make a much smaller test case, but removing any part of the attached code seems to completely break it. I read through the subString implementation with great care, and I believe the warning is wrong, it is impossible to access a -1 offset, unless there is undefined behavior going on. The warning can be fixed by declaring a temporary variable temp in place of the expression length + 1, and using temp - 1 to set the null terminator at the end. I thought this meant that the warning simply saw the array[length] = 0 as a common "wrong" pattern, but that was not enough to reproduce it, so clearly something stranger is afoot.