Since the foundation of the patch is detecting and avoiding the overly aggressive folding of unterminated char arrays, besides issuing a warning for such arguments to strlen, the patch also fixes pr86711 - wrong folding of memchr, and pr86714 - tree-ssa-forwprop.c confused by too long initializer. The substance of the attached updated patch is unchanged, I have just added test cases for the two additional bugs. Bernd, as I mentioned Wednesday, the patch supersedes yours here: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg01800.html Martin On 07/30/2018 01:17 PM, Martin Sebor wrote: > Attached is an updated version of the patch that handles more > instances of calling strlen() on a constant array that is not > a nul-terminated string. > > No other functions except strlen are explicitly handled yet, > and neither are constant arrays with braced-initializer lists > like const char a[] = { 'a', 'b', 'c' }; I am testing > an independent solution for those (bug 86552). Once those > are handled the warning will be able to detect those as well. > > Tested on x86_64-linux. > > On 07/25/2018 05:38 PM, Martin Sebor wrote: >> Ping: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg01124.html >> >> The fix for bug 86532 has been checked in so this enhancement >> can now be applied on top of it (with only minor adjustments). >> >> On 07/19/2018 02:08 PM, Martin Sebor wrote: >>> In the discussion of my patch for pr86532 Bernd noted that >>> GCC silently accepts constant character arrays with no >>> terminating nul as arguments to strlen (and other string >>> functions). >>> >>> The attached patch is a first step in detecting these kinds >>> of bugs in strlen calls by issuing -Wstringop-overflow. >>> The next step is to modify all other handlers of built-in >>> functions to detect the same problem (not part of this patch). >>> Yet another step is to detect these problems in arguments >>> initialized using the non-string form: >>> >>> const char a[] = { 'a', 'b', 'c' }; >>> >>> This patch is meant to apply on top of the one for bug 86532 >>> (I tested it with an earlier version of that patch so there >>> is code in the context that does not appear in the latest >>> version of the other diff). >>> >>> Martin >>> >> >