This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to fix -Wrestrict ICE (PR middle-end/83463)
On Mon, Dec 18, 2017 at 05:03:22PM -0700, Martin Sebor wrote:
> > Your warning is about restrict and argument overlap, what does it have to do
> > with unprototyped calls? Nothing. There is no restrict in that case, and
> > it isn't handled as builtin if it doesn't match the builtin's prototype.
>
> $ cat a.c && gcc -O2 -S -Wrestrict a.c
> void* memcpy ();
>
> char a[5];
>
> void f (void)
> {
> memcpy (a, a + 1, 3);
> }
> a.c: In function ‘f’:
> a.c:7:3: warning: ‘memcpy’ accessing 3 bytes at offsets 0 and 1 overlaps 2
> bytes at offset 1 [-Wrestrict]
> memcpy (a, a + 1, 3);
> ^~~~~~~~~~~~~~~~~~~~
>
> By insisting on using gimple_call_builtin_p() you're effectively
> arguing to disable the warning above, for no good reason that I
> can see.
Because it is wrong.
Consider e.g.
void *mempcpy ();
void
foo (int *a)
{
mempcpy (a, (float *) a + 1, ' ');
}
mempcpy isn't defined in ISO C99, so it is fine if you define it yourself
with void *mempcpy (int *, float *, char); prototype and do whatever you
want in there. Warning about restrict doesn't make sense in that case.
Jakub