Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-29 Thread Jeff Law
On 08/02/2018 12:56 PM, Bernd Edlinger wrote: > On 08/02/18 15:26, Bernd Edlinger wrote: >>> >>>    /* If the length can be computed at compile-time, return it.  */ >>> -  len = c_strlen (src, 0); >>> +  tree array; >>> +  tree len = c_strlen (src, 0, ); >> >> You know the c_strlen tries to

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-26 Thread Bernd Edlinger
On 08/25/18 22:42, Martin Sebor wrote: > On 08/25/2018 01:32 PM, Bernd Edlinger wrote: >> On 08/25/18 21:02, Jeff Law wrote: >>> On 08/25/2018 12:36 PM, Bernd Edlinger wrote: >>> >>> >> >> Well, ya call it "layer one patch over the other" >> I call it "incremental improvements".

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Jeff Law
On 08/25/2018 01:32 PM, Bernd Edlinger wrote: > On 08/25/18 21:02, Jeff Law wrote: >> On 08/25/2018 12:36 PM, Bernd Edlinger wrote: >> >> > > Well, ya call it "layer one patch over the other" > I call it "incremental improvements". It is (of course) a case by case basis. The

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Martin Sebor
On 08/25/2018 01:32 PM, Bernd Edlinger wrote: On 08/25/18 21:02, Jeff Law wrote: On 08/25/2018 12:36 PM, Bernd Edlinger wrote: Well, ya call it "layer one patch over the other" I call it "incremental improvements". It is (of course) a case by case basis. The way I try to look at these

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Bernd Edlinger
On 08/25/18 21:02, Jeff Law wrote: > On 08/25/2018 12:36 PM, Bernd Edlinger wrote: > > Well, ya call it "layer one patch over the other" I call it "incremental improvements". >>> It is (of course) a case by case basis. The way I try to look at these >>> things is to ask

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Jeff Law
On 08/25/2018 12:36 PM, Bernd Edlinger wrote: >>> >>> Well, ya call it "layer one patch over the other" >>> I call it "incremental improvements". >> It is (of course) a case by case basis. The way I try to look at these >> things is to ask whether or not the first patch under consideration

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Bernd Edlinger
On 08/25/18 19:32, Jeff Law wrote: > On 08/25/2018 12:32 AM, Bernd Edlinger wrote: >> On 08/25/18 01:54, Jeff Law wrote: >>> On 08/24/2018 11:26 AM, Bernd Edlinger wrote: On 08/24/18 18:51, Jeff Law wrote: >> Well, this is broken for wide character strings. >> but I hope we can get

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Jeff Law
On 08/25/2018 12:32 AM, Bernd Edlinger wrote: > On 08/25/18 01:54, Jeff Law wrote: >> On 08/24/2018 11:26 AM, Bernd Edlinger wrote: >>> On 08/24/18 18:51, Jeff Law wrote: > Well, this is broken for wide character strings. > but I hope we can get rid of STRING_CST which are > not

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-25 Thread Bernd Edlinger
On 08/25/18 01:54, Jeff Law wrote: > On 08/24/2018 11:26 AM, Bernd Edlinger wrote: >> On 08/24/18 18:51, Jeff Law wrote: Well, this is broken for wide character strings. but I hope we can get rid of STRING_CST which are not explicitly null terminated. >> >> I am afraid that is not

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Jeff Law
On 08/24/2018 11:26 AM, Bernd Edlinger wrote: > On 08/24/18 18:51, Jeff Law wrote: >>> Well, this is broken for wide character strings. >>> but I hope we can get rid of STRING_CST which are >>> not explicitly null terminated. > > I am afraid that is not going to happen. > Maybe we can get

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Bernd Edlinger
On 08/24/18 18:04, Jeff Law wrote: > On 08/24/2018 06:27 AM, Bernd Edlinger wrote: > [ Lots of snipping throughout ] > > > + > if (TREE_CODE (src) == COND_EXPR > && (only_value || !TREE_SIDE_EFFECTS (TREE_OPERAND (src, 0 >{ > - tree len1,

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Bernd Edlinger
On 08/24/18 18:51, Jeff Law wrote: > On 08/02/2018 07:26 AM, Bernd Edlinger wrote: >> >>> - if (compare_tree_int (array_size, length + 1) < 0) >>> + if (nulterm) >> but here you compare bytes with length which is measued un chars. >> >>> +*nulterm = array_elts > length; >>> + else if

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Jeff Law
On 08/02/2018 07:26 AM, Bernd Edlinger wrote: > >> - if (compare_tree_int (array_size, length + 1) < 0) >> + if (nulterm) > but here you compare bytes with length which is measued un chars. > >> +*nulterm = array_elts > length; >> + else if (array_elts <= length) >> return NULL_TREE;

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Jeff Law
On 08/24/2018 06:27 AM, Bernd Edlinger wrote: [ Lots of snipping throughout ] >>> + if (TREE_CODE (src) == COND_EXPR && (only_value || !TREE_SIDE_EFFECTS (TREE_OPERAND (src, 0 { - tree len1, len2; - - len1 = c_strlen

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Bernd Edlinger
On 08/24/18 08:36, Jeff Law wrote: > On 08/02/2018 07:26 AM, Bernd Edlinger wrote: >> On 08/02/18 04:44, Martin Sebor wrote: >>> Since the foundation of the patch is detecting and avoiding >>> the overly aggressive folding of unterminated char arrays, >>> besides issuing a warning for such

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-24 Thread Jeff Law
On 08/02/2018 07:26 AM, Bernd Edlinger wrote: > On 08/02/18 04:44, Martin Sebor wrote: >> 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

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-17 Thread Martin Sebor
On 08/16/2018 11:14 PM, Jeff Law wrote: On 08/01/2018 08:44 PM, Martin Sebor wrote: 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

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-16 Thread Jeff Law
On 08/01/2018 08:44 PM, Martin Sebor wrote: > 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 -

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-14 Thread Jeff Law
On 08/03/2018 07:00 AM, Bernd Edlinger wrote: > On 08/02/18 22:34, Martin Sebor wrote: >> On 08/02/2018 12:56 PM, Bernd Edlinger wrote: >>> On 08/02/18 15:26, Bernd Edlinger wrote: > >    /* If the length can be computed at compile-time, return it.  */ > -  len = c_strlen (src, 0);

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-03 Thread Martin Sebor
On 08/03/2018 07:00 AM, Bernd Edlinger wrote: On 08/02/18 22:34, Martin Sebor wrote: On 08/02/2018 12:56 PM, Bernd Edlinger wrote: On 08/02/18 15:26, Bernd Edlinger wrote: /* If the length can be computed at compile-time, return it. */ - len = c_strlen (src, 0); + tree array; + tree

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-03 Thread Bernd Edlinger
On 08/02/18 22:34, Martin Sebor wrote: > On 08/02/2018 12:56 PM, Bernd Edlinger wrote: >> On 08/02/18 15:26, Bernd Edlinger wrote:    /* If the length can be computed at compile-time, return it.  */ -  len = c_strlen (src, 0); +  tree array; +  tree len = c_strlen (src, 0,

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-02 Thread Martin Sebor
On 08/02/2018 12:56 PM, Bernd Edlinger wrote: On 08/02/18 15:26, Bernd Edlinger wrote: /* If the length can be computed at compile-time, return it. */ - len = c_strlen (src, 0); + tree array; + tree len = c_strlen (src, 0, ); You know the c_strlen tries to compute wide character

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-02 Thread Bernd Edlinger
On 08/02/18 15:26, Bernd Edlinger wrote: >> >>    /* If the length can be computed at compile-time, return it.  */ >> -  len = c_strlen (src, 0); >> +  tree array; >> +  tree len = c_strlen (src, 0, ); > > You know the c_strlen tries to compute wide character sizes, > but strlen does not do that,

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-02 Thread Bernd Edlinger
On 08/02/18 04:44, Martin Sebor wrote: > 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 -

PING [PATCH] warn for strlen of arrays with missing nul (PR 86552, 86711, 86714) )

2018-08-01 Thread Martin Sebor
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

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-08-01 Thread Martin Sebor
On 08/01/2018 10:34 AM, Martin Sebor wrote: If you care about detecting bugs I would expect you to be supportive rather than dismissive of this work, and helpful in bringing it to fruition rather that putting it down or questioning my priorities. Especially since the work was prompted by your

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-08-01 Thread Bernd Edlinger
On 08/01/18 18:34, Martin Sebor wrote: >>> If you care about detecting bugs I would expect you to be >>> supportive rather than dismissive of this work, and helpful >>> in bringing it to fruition rather that putting it down or >>> questioning my priorities.  Especially since the work was >>>

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-08-01 Thread Martin Sebor
If you care about detecting bugs I would expect you to be supportive rather than dismissive of this work, and helpful in bringing it to fruition rather that putting it down or questioning my priorities. Especially since the work was prompted by your own (valid) complaint that GCC doesn't

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-08-01 Thread Bernd Edlinger
On 07/31/18 05:51, Martin Sebor wrote: > On 07/30/2018 03:11 PM, Bernd Edlinger wrote: >> Hi, >> >>> @@ -621,6 +674,12 @@ c_strlen (tree src, int only_value) >>> maxelts = maxelts / eltsize - 1; >>>   } >>> >>> +  /* Unless the caller is prepared to handle it by passing in a non-null >>> + 

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-07-30 Thread Martin Sebor
On 07/30/2018 03:11 PM, Bernd Edlinger wrote: Hi, @@ -621,6 +674,12 @@ c_strlen (tree src, int only_value) maxelts = maxelts / eltsize - 1; } + /* Unless the caller is prepared to handle it by passing in a non-null + ARR, fail if the terminating nul doesn't fit in the array

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-07-30 Thread Bernd Edlinger
Hi, >@@ -621,6 +674,12 @@ c_strlen (tree src, int only_value) > maxelts = maxelts / eltsize - 1; > } > >+ /* Unless the caller is prepared to handle it by passing in a non-null >+ ARR, fail if the terminating nul doesn't fit in the array the string >+ is stored in (as in

Re: PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-07-30 Thread Martin Sebor
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[] = {

PING [PATCH] warn for strlen of arrays with missing nul (PR 86552)

2018-07-25 Thread Martin Sebor
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