This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] string: Add tests for zero length string inputs


Richard Earnshaw wrote:

if src+1 can point outside of the address space of the program

As Andreas points out, src+1 does not point outside the address space of the program. It is a valid pointer.

My reading of those sections also leads me to believe that memcpy could
legitimately expect to perform "*(char*)dst = *(char*)dst", even if the
length is zero.

I'm sorry, but this reading is incorrect. If the size is zero, memcpy cannot store any bytes into the destination. Any memcpy that does otherwise would break a lot of programs.

I can think of no reason why 7.21.1/2 would explicitly
require valid pointers when the length parameter was 0 unless it was
intended that dereferencing could occur.

It caters to (unusual) architectures that require valid pointers in address registers even when the pointers are not dereferenced, e.g., loading a pointer into an address register will trap if the pointer is invalid.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]