This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] avoid warning for memcpy to self (PR 83456)
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 8 Mar 2018 09:59:35 +0100
- Subject: Re: [PATCH] avoid warning for memcpy to self (PR 83456)
- Authentication-results: sourceware.org; auth=none
- References: <2db2b46a-b716-4a3c-1e42-a066e40d85c7@gmail.com>
On Thu, Mar 8, 2018 at 12:01 AM, Martin Sebor <msebor@gmail.com> wrote:
> I have become convinced that issuing -Wrestrict in gimple-fold
> for calls to memcpy() where the source pointer is the same as
> the destination causes more trouble than it's worth, especially
> when inlining is involved, as in:
>
> inline void bar (void *d, void *s, unsigned N)
> {
> if (s != d)
> memcpy (d, s, N);
> }
>
> void foo (void* src)
> {
> bar (src, src, 1);
> }
>
> It seems that there should be a way to teach GCC to avoid
> folding statements in dead blocks (e.g., in a block controlled
> by 'if (0 != 0)' as the one below), and that it might even speed
> up compilation, but in the meantime it leads to false positive
> -Wrestrict warnings.
>
> The attached patch removes this instance of the warning and
> adjusts tests not to expect it.
Ok.
Richard.
> Martin