From: drew@ophelia.cs.colorado.edu (Drew Eckhardt) Subject: Re: libc? memcpy does not rcognize overlapping blocks Date: Wed, 14 Jul 1993 00:02:23 GMT
In article <21rtif$qqh@nz12.rz.uni-karlsruhe.de> "Gerd Klesse" <LH04@IBM3090.RZ.UNI-KARLSRUHE.DE> writes:
>Hi out there!
>
>When using 'memcpy' with old TURBO C in ancient days, I was
>used to 'memcpy' to respect overlapping areas. So having
>int testarray{10};
>memcpy(testarray + 1, testarray, sizeof(int));
>this will shift my 'testarray' one element up.
>(please excuse the wrong parantheses, but my damn keyboard is not
>able to produce the right ones.) But with gcc-2.4.3 and the
>library 4.4.0 I got a multiplication of the first element over the
>whole array.
>
>Is this a bug or a feature?
The 'C' standard doesn't guarantee that memcpy() will handle overlapping
areas correctly. memmove() is the function you're looking for.
-- Boycott USL/Novell for their absurd anti-BSDI lawsuit. | Condemn Colorado for Amendment Two. | Drew Eckhardt Use Linux, the fast, flexible, and free 386 unix | drew@cs.Colorado.EDU Will administer Unix for food |