Re: [patch] libstdc++/66327 don't pass null pointers to memcmp

2015-05-30 Thread Jonathan Wakely
On 30/05/15 09:36 +, Jörg Richter wrote: How about comparing only the length against 0? The pointers must be != 0 if length 0. Like so? Yes, that's probably an improvement, because we need that length anyway. Yes, that is what I had in mind. I think the second case can be handled equally

[patch] libstdc++/66327 don't pass null pointers to memcmp

2015-05-28 Thread Jonathan Wakely
std::equal((int*)0, (int*)0, p) and std::equal(p, p, (int*)0) are valid for any input iterator p, and must not pass a null pointer to memcpy. Similarly, std::lexicographical_compare((int*)0, (int*)0, p, q) and std::lexicographical_compare(p, q, (int*)0, (int*)0) are valid for any input iterators