[LLVMdev] memcpy(), memmove(), and memset() with zero length
Dale Johannesen
dalej at apple.com
Sat Oct 6 09:18:09 PDT 2007
On Oct 6, 2007, at 9:02 AM, Jon Sargeant wrote:
> If I copy or set zero bytes with memcpy(), memmove(), or memset(), can
> the <dest> and <src> arguments be null? Can they be invalid pointers?
This is covered in 7.21.1.p2 of C99 (C++ just points to the C standard):
Where an argument declared as size_t n specifies the length of the
array for a
function, n can have the value zero on a call to that function.
Unless explicitly stated
otherwise in the description of a particular function in this
subclause, pointer arguments
on such a call shall still have valid values, as described in 7.1.4.
On such a call, a
function that locates a character finds no occurrence, a function
that compares two
character sequences returns zero, and a function that copies
characters copies zero
characters.
More information about the llvm-dev
mailing list