Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-18 Thread Martin Sebor
On 12/14/2017 12:04 PM, Jeff Law wrote: On 12/14/2017 11:55 AM, Jakub Jelinek wrote: On Thu, Dec 14, 2017 at 11:51:26AM -0700, Martin Sebor wrote: Well, it would be nice to get sanitizers diagnose this at runtime. If we know the array length at compile time, simply compare after the strlen

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-16 Thread Martin Sebor
On 12/15/2017 10:29 AM, Martin Sebor wrote: On 12/15/2017 09:17 AM, Richard Biener wrote: On December 15, 2017 4:58:14 PM GMT+01:00, Martin Sebor wrote: On 12/15/2017 01:48 AM, Richard Biener wrote: On Thu, Dec 14, 2017 at 5:01 PM, Martin Sebor wrote:

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-15 Thread Martin Sebor
On 12/15/2017 09:17 AM, Richard Biener wrote: On December 15, 2017 4:58:14 PM GMT+01:00, Martin Sebor wrote: On 12/15/2017 01:48 AM, Richard Biener wrote: On Thu, Dec 14, 2017 at 5:01 PM, Martin Sebor wrote: On 12/14/2017 03:43 AM, Richard Biener wrote:

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-15 Thread Richard Biener
On December 15, 2017 4:58:14 PM GMT+01:00, Martin Sebor wrote: >On 12/15/2017 01:48 AM, Richard Biener wrote: >> On Thu, Dec 14, 2017 at 5:01 PM, Martin Sebor >wrote: >>> On 12/14/2017 03:43 AM, Richard Biener wrote: On Wed, Dec 13, 2017 at 4:47 AM,

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-15 Thread Martin Sebor
On 12/15/2017 01:48 AM, Richard Biener wrote: On Thu, Dec 14, 2017 at 5:01 PM, Martin Sebor wrote: On 12/14/2017 03:43 AM, Richard Biener wrote: On Wed, Dec 13, 2017 at 4:47 AM, Martin Sebor wrote: On 12/12/2017 05:35 PM, Jeff Law wrote: On

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-15 Thread Richard Biener
On Thu, Dec 14, 2017 at 5:01 PM, Martin Sebor wrote: > On 12/14/2017 03:43 AM, Richard Biener wrote: >> >> On Wed, Dec 13, 2017 at 4:47 AM, Martin Sebor wrote: >>> >>> On 12/12/2017 05:35 PM, Jeff Law wrote: On 12/12/2017 01:15 PM, Martin Sebor

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Jeff Law
On 12/14/2017 11:55 AM, Jakub Jelinek wrote: > On Thu, Dec 14, 2017 at 11:51:26AM -0700, Martin Sebor wrote: >>> Well, it would be nice to get sanitizers diagnose this at runtime. If we >>> know the array length at compile time, simply compare after the strlen >>> call the result and fail if it

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Jakub Jelinek
On Thu, Dec 14, 2017 at 11:51:26AM -0700, Martin Sebor wrote: > > Well, it would be nice to get sanitizers diagnose this at runtime. If we > > know the array length at compile time, simply compare after the strlen > > call the result and fail if it returns something above it. Or replace > > the

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Martin Sebor
On 12/14/2017 09:18 AM, Jakub Jelinek wrote: On Thu, Dec 14, 2017 at 09:13:21AM -0700, Jeff Law wrote: Although I would prefer not to, I suppose if letting strlen cross the boundaries of subobjects was considered an important use to accommodate in limited cases the optimization could be

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Jakub Jelinek
On Thu, Dec 14, 2017 at 09:13:21AM -0700, Jeff Law wrote: > > Although I would prefer not to, I suppose if letting strlen cross > > the boundaries of subobjects was considered an important use to > > accommodate in limited cases the optimization could be disabled > > for member arrays declared

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Jeff Law
On 12/12/2017 08:47 PM, Martin Sebor wrote: >> >> struct fu { >>   char x1[10]; >>   char x2[10]; >>   int avoid_trailing_array; >> } >> >> Where objects stored in x1 are not null terminated.  Are we in the realm >> of undefined behavior at that point (I hope so)? > > Yes, this is undefined. 

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Martin Sebor
On 12/14/2017 03:43 AM, Richard Biener wrote: On Wed, Dec 13, 2017 at 4:47 AM, Martin Sebor wrote: On 12/12/2017 05:35 PM, Jeff Law wrote: On 12/12/2017 01:15 PM, Martin Sebor wrote: Bug 83373 - False positive reported by -Wstringop-overflow, is another example of warning

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-14 Thread Richard Biener
On Wed, Dec 13, 2017 at 4:47 AM, Martin Sebor wrote: > On 12/12/2017 05:35 PM, Jeff Law wrote: >> >> On 12/12/2017 01:15 PM, Martin Sebor wrote: >>> >>> Bug 83373 - False positive reported by -Wstringop-overflow, is >>> another example of warning triggered by a missed

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-13 Thread Martin Sebor
On 12/13/2017 12:25 AM, Bernhard Reutner-Fischer wrote: On 12 December 2017 21:15:25 CET, Martin Sebor wrote: Tested on x86_64-linux. I assume this test worked even before this patch. Of the tests added by the patch, strlenopt-37.c passes without the compiler changes

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-12 Thread Bernhard Reutner-Fischer
On 12 December 2017 21:15:25 CET, Martin Sebor wrote: > >Tested on x86_64-linux. I assume this test worked even before this patch. Thus: s/oveflow/overflow/ thanks,

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-12 Thread Martin Sebor
On 12/12/2017 05:35 PM, Jeff Law wrote: On 12/12/2017 01:15 PM, Martin Sebor wrote: Bug 83373 - False positive reported by -Wstringop-overflow, is another example of warning triggered by a missed optimization opportunity, this time in the strlen pass. The optimization is discussed in pr78450 -

Re: [PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-12 Thread Jeff Law
On 12/12/2017 01:15 PM, Martin Sebor wrote: > Bug 83373 - False positive reported by -Wstringop-overflow, is > another example of warning triggered by a missed optimization > opportunity, this time in the strlen pass.  The optimization > is discussed in pr78450 - strlen(s) return value can be

[PATCH] set range for strlen(array) to avoid spurious -Wstringop-overflow (PR 83373 , PR 78450)

2017-12-12 Thread Martin Sebor
Bug 83373 - False positive reported by -Wstringop-overflow, is another example of warning triggered by a missed optimization opportunity, this time in the strlen pass. The optimization is discussed in pr78450 - strlen(s) return value can be assumed to be less than the size of s. The gist of it