[Coco] Fwd: MW-C Cross compiler bug - Solved

Gene Heskett gheskett at wdtv.com
Sun Mar 9 19:25:30 EDT 2014


On Sunday 09 March 2014 19:23:17 Luis Antoniosi (CoCoDemus) did opine:

> But why are we discussing K&R if the C cross compiler is being
> compiled using modern gcc on PCs ?

Because ideally, the two guys who wrote the language in the first place, 
deserve to have their updated #2, ANSI version of the language treated as 
the final arbiter of how it is supposed to be done.
 
> strcpy and memcpy have been optimized specially for use with RISC CPUs
> to avoid LHS.
> 
> On Sun, Mar 9, 2014 at 5:55 PM, Gene Heskett <gheskett at wdtv.com> wrote:
> > On Sunday 09 March 2014 17:42:49 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
> > 
> > I was gonna pull my copy down and quote its entries for strcpy(s,ct)
> > and strncpy(s,ct,n) but I've apparently pulled it down for reference
> > and laid it someplace in this midden heap, hopefully not forever. 
> > Ah, just found it, shove under the monitor right in front of me.
> > 
> > There is no discussion as to the gotchas in using strcpy vs memcpy in
> > K&R #2.  At first glance they look interchangeable except strcpy
> > would apparently stop the copy at the EOL character since it expects
> > no n argument.  strncpy(s,ct,n) would appear to be exactly the same
> > as memcpy(s,ct,n) in its effect.  But does our clib even have the
> > memcpy?  I haven't looked in yonks.
> > 
> > 
> > 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>
> > 
> > 
> > --
> > 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