Hacker News new | ask | show | jobs
by grn 4843 days ago
It's also worth pointing out that buffers passed to strcpy, memcpy, etc. must not overlap. Otherwise it results in undefined behavior.
3 comments

It has come up in the past that this distinction is a historical artifact rather than a necessity. Linus tried to get Ulrich to change this in glibc, but it was not changed.

http://www.sourceware.org/bugzilla/show_bug.cgi?id=12518

That's stdlib though, not the language.
The standard library is part of the language - all hosted implementations must provide it.

This allows, for example, compilers to replace a `memcpy()` call that has a constant size argument with direct loads/stores.

memmove() has proper memory moving semantics, and can deal with overlapping buffers.