[Coco] Fwd: MW-C Cross compiler bug - Solved
Gene Heskett
gheskett at wdtv.com
Sun Mar 9 19:19:30 EDT 2014
On Sunday 09 March 2014 19:07:43 Chris Osborn did opine:
> On Mar 9, 2014, at 2:01 PM, Gene Heskett wrote:
> > Are you saying that both of my copies (original and the "ANSI C"
> > versions of the K&R books are wrong?
>
> Page 250 of my ANSI K&R 2nd Edition book says:
>
> void *memcpy(s,ct,n) copy n characters from ct to s, and return
s.
> void *memmove(s,ct,n) same as memcpy except that it works even if the
> objects overlap.
>
> So yes, you're supposed to use memmove.
>
> The memcpy vs. memmove saga:
>
> http://www.win.tue.nl/~aeb/linux/misc/gcc-semibug.html
>
This link would be a lot more useful if it had dates to go along with the
versions involved. As is, I have no clue if that is last weeks post, or a
decade old.
So what happens when memcpy encounters the first 2 args, and discovers they
are less than n apart?
And can one assume that if they overlap when n is accounted for, that its
smart enough do a reverse copy order if the overlap means it would be
copying data it has already copied.
Gotta be more smarts than what I am reading. Sometimes K&R can be too
darned concise for ultimate clarity of meaning.
Bottom line? One should probably use memmove IF its available on that
platform. But pay attention to the platforms EOL convention religiously
too.
And I withdraw my objection.
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the Coco
mailing list