Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-25 Thread Siddhesh Poyarekar
On 25/03/2022 18:56, Jason Merrill via Gcc-patches wrote: Perhaps a suitable compromise would be to add a separate warning flag specifically for the strn* warnings, so users deliberately using the bound to express a limit other than the length of the argument string (and confident that their

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-25 Thread Jason Merrill via Gcc-patches
On 3/17/22 06:35, Jonathan Wakely via Gcc-patches wrote: On 15/03/22 14:36 -0600, Martin Sebor wrote: On 3/15/22 10:40, Siddhesh Poyarekar wrote: On 15/03/2022 21:09, Martin Sebor wrote: The strncmp function takes arrays as arguments (not necessarily strings).? The main purpose of the

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Martin Sebor via Gcc-patches
On 3/17/22 12:02, Siddhesh Poyarekar wrote: On 17/03/2022 23:21, Martin Sebor wrote: On 3/17/22 11:22, Siddhesh Poyarekar wrote: On 17/03/2022 22:16, Jeff Law wrote:     #include     char a[] = "abc";     char b[] = "abcd";     int f (void)     {   return strncmp (a, b, 8);     }    

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Siddhesh Poyarekar
On 17/03/2022 23:21, Martin Sebor wrote: On 3/17/22 11:22, Siddhesh Poyarekar wrote: On 17/03/2022 22:16, Jeff Law wrote:     #include     char a[] = "abc";     char b[] = "abcd";     int f (void)     {   return strncmp (a, b, 8);     }     where I get     t.c:7:10: warning: ‘strncmp’

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Martin Sebor via Gcc-patches
On 3/17/22 11:22, Siddhesh Poyarekar wrote: On 17/03/2022 22:16, Jeff Law wrote:     #include     char a[] = "abc";     char b[] = "abcd";     int f (void)     {   return strncmp (a, b, 8);     }     where I get     t.c:7:10: warning: ‘strncmp’ specified bound 8 exceeds source size 5   

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Siddhesh Poyarekar
On 17/03/2022 22:16, Jeff Law wrote: #include char a[] = "abc"; char b[] = "abcd"; int f (void) {   return strncmp (a, b, 8); } where I get t.c:7:10: warning: ‘strncmp’ specified bound 8 exceeds source size 5 [-Wstringop-overread]     7 |   

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Andreas Schwab
On Mär 17 2022, Jeff Law via Gcc-patches wrote: > On Thu, Mar 17, 2022 at 9:32 AM Marek Polacek via Gcc-patches < > gcc-patches@gcc.gnu.org> wrote: >> I think I agree, I've tried >> >> #include >> char a[] = "abc"; >> char b[] = "abcd"; >> >> int f (void) >> { >> return strncmp (a, b, 8); >> }

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Jeff Law via Gcc-patches
On Thu, Mar 17, 2022 at 9:32 AM Marek Polacek via Gcc-patches < gcc-patches@gcc.gnu.org> wrote: > On Wed, Mar 16, 2022 at 06:54:51AM +0530, Siddhesh Poyarekar wrote: > > On 16/03/2022 02:06, Martin Sebor wrote: > > > The intended use of the strncmp bound is to limit the comparison to > > > at

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Marek Polacek via Gcc-patches
On Wed, Mar 16, 2022 at 06:54:51AM +0530, Siddhesh Poyarekar wrote: > On 16/03/2022 02:06, Martin Sebor wrote: > > The intended use of the strncmp bound is to limit the comparison to > > at most the size of the arrays or (in a subset of cases) the length > > of an initial substring. Providing an

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Aldy Hernandez via Gcc-patches
I agree with Siddhesh (and Jonathan). Is there a release manager that can either review his patch, or provide feedback as to what the course of action should be here? Thanks. Aldy On Thu, Mar 17, 2022 at 2:44 AM Siddhesh Poyarekar wrote: > > On 17/03/2022 05:11, Martin Sebor wrote: > > As the

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread David Malcolm via Gcc-patches
On Tue, 2022-03-15 at 22:10 +0530, Siddhesh Poyarekar wrote: > On 15/03/2022 21:09, Martin Sebor wrote: > > The strncmp function takes arrays as arguments (not necessarily > > strings).  The main purpose of the -Wstringop-overread warning > > for calls to it is to detect calls where one of the

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Jonathan Wakely via Gcc-patches
On 15/03/22 14:36 -0600, Martin Sebor wrote: On 3/15/22 10:40, Siddhesh Poyarekar wrote: On 15/03/2022 21:09, Martin Sebor wrote: The strncmp function takes arrays as arguments (not necessarily strings).? The main purpose of the -Wstringop-overread warning for calls to it is to detect calls

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-16 Thread Siddhesh Poyarekar
On 17/03/2022 05:11, Martin Sebor wrote: As the GCC manual prominently states (and as I already pointed out) warnings are: We are indeed going around in circles. Hopefully someone else will pitch in and break the deadlock. Siddhesh

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-16 Thread Martin Sebor via Gcc-patches
On 3/15/22 19:24, Siddhesh Poyarekar wrote: On 16/03/2022 02:06, Martin Sebor wrote: The intended use of the strncmp bound is to limit the comparison to at most the size of the arrays or (in a subset of cases) the length of an initial substring. Providing an arbitrary bound that's not related

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-15 Thread Siddhesh Poyarekar
On 16/03/2022 02:06, Martin Sebor wrote: The intended use of the strncmp bound is to limit the comparison to at most the size of the arrays or (in a subset of cases) the length of an initial substring. Providing an arbitrary bound that's not related to the sizes as you describe sounds very much

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-15 Thread Martin Sebor via Gcc-patches
On 3/15/22 10:40, Siddhesh Poyarekar wrote: On 15/03/2022 21:09, Martin Sebor wrote: The strncmp function takes arrays as arguments (not necessarily strings).  The main purpose of the -Wstringop-overread warning for calls to it is to detect calls where one of the arrays is not a nul-terminated

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-15 Thread Siddhesh Poyarekar
On 15/03/2022 21:09, Martin Sebor wrote: The strncmp function takes arrays as arguments (not necessarily strings).  The main purpose of the -Wstringop-overread warning for calls to it is to detect calls where one of the arrays is not a nul-terminated string and the bound is larger than the size

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-15 Thread Martin Sebor via Gcc-patches
On 3/14/22 23:31, Siddhesh Poyarekar wrote: The size argument in strncmp only describe the maximum length to which to compare two strings and is not an indication of sizes of the two source strings. Do not warn if it is larger than the two input strings because it is entirely likely that the