Jon Sargeant
2007-Oct-06 16:02 UTC
[LLVMdev] memcpy(), memmove(), and memset() with zero length
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? Regards, Jon
Dale Johannesen
2007-Oct-06 16:18 UTC
[LLVMdev] memcpy(), memmove(), and memset() with zero length
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.
Reasonably Related Threads
- Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?
- Change memcpy/memmove/memset to have dest and source alignment attributes
- Change memcpy/memmove/memset to have dest and source alignment attributes
- [LLVMdev] Specify the volatile access behaviour of the memcpy, memmove and memset intrinsics
- Change memcpy/memmove/memset to have dest and source alignment attributes