Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Martin Sebor
On 06/13/2018 09:16 AM, Jakub Jelinek wrote: On Wed, Jun 13, 2018 at 08:53:20AM -0600, Martin Sebor wrote: I'm actually worried about the fold-const.c change and don't understand, why it has been done at all in the context of this PR. case SAVE_EXPR: if (flags &

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Jakub Jelinek
On Wed, Jun 13, 2018 at 08:53:20AM -0600, Martin Sebor wrote: > > I'm actually worried about the fold-const.c change and don't understand, why > > it has been done at all in the context of this PR. > > > > case SAVE_EXPR: > > if (flags & OEP_LEXICOGRAPHIC) > > return

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Martin Sebor
On 06/13/2018 01:58 AM, Jakub Jelinek wrote: On Wed, Jun 13, 2018 at 09:46:28AM +0200, Richard Biener wrote: gcc/ChangeLog: PR c/85931 * fold-const.c (operand_equal_p): Handle SAVE_EXPR. gcc/testsuite/ChangeLog: PR c/85931 * gcc.dg/Wstringop-truncation-3.c:

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Jakub Jelinek
On Wed, Jun 13, 2018 at 10:51:41AM +0200, Richard Biener wrote: > Your concern is for compile-time, not for correctness, right? Yes. > I think that > > /* If ARG0 and ARG1 are the same SAVE_EXPR, they are necessarily equal. > We don't care about side effects in that case because the

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Richard Biener
On Wed, 13 Jun 2018, Jakub Jelinek wrote: > On Wed, Jun 13, 2018 at 10:22:29AM +0200, Jakub Jelinek wrote: > > Random testcase for -Wduplicated-branches -fsanitize=shift: > > int > > foo (int x, int y) > > { > > if (x) > > y = y << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 <<

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Jakub Jelinek
On Wed, Jun 13, 2018 at 10:22:29AM +0200, Jakub Jelinek wrote: > Random testcase for -Wduplicated-branches -fsanitize=shift: > int > foo (int x, int y) > { > if (x) > y = y << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> 1 << 1 >> > 1 << 1 >> 1 > << 1 >> 1 << 1 >> 1 << 1

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Jakub Jelinek
On Wed, Jun 13, 2018 at 09:58:49AM +0200, Jakub Jelinek wrote: > I'm actually worried about the fold-const.c change and don't understand, why > it has been done at all in the context of this PR. > > case SAVE_EXPR: > if (flags & OEP_LEXICOGRAPHIC) > return OP_SAME

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Jakub Jelinek
On Wed, Jun 13, 2018 at 09:46:28AM +0200, Richard Biener wrote: > > > > gcc/ChangeLog: > > > > > > > > PR c/85931 > > > > * fold-const.c (operand_equal_p): Handle SAVE_EXPR. > > > > > > > > gcc/testsuite/ChangeLog: > > > > > > > > PR c/85931 > > > > *

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-13 Thread Richard Biener
On Tue, 12 Jun 2018, Martin Sebor wrote: > On 06/11/2018 03:57 PM, Jeff Law wrote: > > On 05/29/2018 08:57 PM, Martin Sebor wrote: > > > Warning for a strncpy call whose bound is the same as the size > > > of the source and suggesting to use the size of the source is > > > less than helpful when

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-12 Thread Martin Sebor
On 06/11/2018 03:57 PM, Jeff Law wrote: On 05/29/2018 08:57 PM, Martin Sebor wrote: Warning for a strncpy call whose bound is the same as the size of the source and suggesting to use the size of the source is less than helpful when both sizes are the same, as in: char a[4], b[4]; strncpy

Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-11 Thread Jeff Law
On 05/29/2018 08:57 PM, Martin Sebor wrote: > Warning for a strncpy call whose bound is the same as the size > of the source and suggesting to use the size of the source is > less than helpful when both sizes are the same, as in: > >   char a[4], b[4]; >   strncpy (a, b, sizeof b); > > The 

PING 2 [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-11 Thread Martin Sebor
Ping: https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01698.html On 06/04/2018 05:50 PM, Martin Sebor wrote: Ping: https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01698.html On 05/29/2018 08:57 PM, Martin Sebor wrote: Warning for a strncpy call whose bound is the same as the size of the source

PING [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-04 Thread Martin Sebor
Ping: https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01698.html On 05/29/2018 08:57 PM, Martin Sebor wrote: Warning for a strncpy call whose bound is the same as the size of the source and suggesting to use the size of the source is less than helpful when both sizes are the same, as in: char

[PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-05-29 Thread Martin Sebor
Warning for a strncpy call whose bound is the same as the size of the source and suggesting to use the size of the source is less than helpful when both sizes are the same, as in: char a[4], b[4]; strncpy (a, b, sizeof b); The attached patch suppresses the -Wsizeof-pointer-memaccess warning