Re: MIT discovered issue with gcc
On Sun, Nov 24, 2013 at 12:18 AM, Robert Baron
> Second question:
> Doesn't memcpy allow for overlapping memory, but strcpy does not? Isn't
> this why memcpy is preferred over strcpy?
The reason memcpy() is preferred over strcpy() is the same as the
reason strncpy() is preferred over strcpy().
memcpy() is actually considered a no-no in some circles, and perhaps
correctly so. (Especially in C++, where classes are supposed to
define their own copying, and it's almost always more optimal to
explicitly copy each member instead of calculating the size, mass
copying, and going back and overwriting the members that are subject
to issues like deep copy. Remember that memcpy() is able to copy an
odd number of bytes, so the size calculation contains a bit more than
is obvious to the programmer.)
Be careful where you see conspiracy.
Look first in your own heart.