memset zero bytes at NULL - isolate-erroneous-paths

Florian Weimer fw@deneb.enyo.de
Mon Nov 18 07:12:00 GMT 2013


* Jeff Law:

>> Is this new in C11?  Does it apply to functions such as strnlen as well?

> No, it's C99 I think.  There was a clarification which came in after
> C99 which clarified that even if the length is zero, the pointers must
> still be valid.

Okay, I found the language in sections 7.1.4 and 7.21.1 (thanks Marc).

This is a bit unfortunate because it interoperates poorly with
std::vector<T>::data(), which can return a null pointer if the vector
is empty.



More information about the Gcc mailing list