Get the latest tech news
Making memcpy(NULL, NULL, 0) well-defined
C2y makes memcpy(NULL, NULL, 0) and other zero-length operations on null pointers well defined. This removes a source of bugs that may result in security issues.
For example, GCC will happily remove the dest == NULL branch in the following code, while Clang deliberately does not perform this optimization: The original proposal was focused on removing UB for memory library calls, but an early reviewer pointed out that this is not sufficient. Special thanks go to David Stone, whose early feedback radically changed the direction of the proposal from memory library calls in particular to "zero-length" operations in general.
Or read this on Hacker News