gcc warns for memmove (0, b, 0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
For the following test-case:

void f(char *b)
{
  __builtin_memmove (0, b, 0);
}

gcc emits the warning:
t2.c: In function ‘f’:
t2.c:3:3: warning: null argument where non-null required (argument 1)
[-Wnonnull]
   __builtin_memmove (0, b, 0);
   ^~~~~~~~~~~~~~~~~

I was wondering if the warning is correct in this case, since we are
passing 3rd argument as 0,
and IIUC, no copying should take place from source to dest and hence
shouldn't matter
if dest is NULL ?

n1570 7.24.2.2 says:
"The memmove function copies n characters from the object pointed to
by s2 into the
object pointed to by s1. Copying takes place as if the n characters
from the object
pointed to by s2 are first copied into a temporary array of n
characters that does not
overlap the objects pointed to by s1 and s2, and then the n characters from the
temporary array are copied into the object pointed to by s1."

I am not sure though how to interpret this in context of above example.

Thanks,
Prathamesh




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux