[PATCH] avoid issuing -Wrestrict from folder (PR 93519)

Richard Biener richard.guenther@gmail.com
Tue Feb 4 09:34:00 GMT 2020


On Tue, Feb 4, 2020 at 1:44 AM Martin Sebor <msebor@gmail.com> wrote:
>
> PR 93519 reports a false positive -Wrestrict issued for an inlined call
> to strcpy that carefully guards against self-copying.  This is caused
> by the caller's arguments substituted into the call during inlining and
> before dead code elimination.
>
> The attached patch avoids this by removing -Wrestrict from the folder
> and deferring folding perfectly overlapping (and so undefined) calls
> to strcpy (and mempcpy, but not memcpy) until much later.  Calls to
> perfectly overlapping calls to memcpy are still folded early.

Why do we bother to warn at all for this case?  Just DWIM here.  Warnings like
this can be emitted from the analyzer?

That is, I suggest to simply remove the bogus warning code from folding
(and _not_ fail the folding).

Richard.

> Tested on x86_64-linux.
>
> Martin



More information about the Gcc-patches mailing list