Re: void * in ANSC



In article <1fad2$47a790c3$541dfcd3$20968@xxxxxxxxxxxxxxxxxxxxxxxx>,
=?UTF-8?q?Harald_van_D=C4=B3k?= <truedfx@xxxxxxxxx> wrote:
On Mon, 04 Feb 2008 22:21:04 +0000, Walter Roberson wrote:
In article <fo6th2$mls$2@xxxxxxxxxxxx>, Army1987 <army1987@xxxxxxxxx>
wrote:
Army1987 wrote:

(void)memcpy(foo, bar, 42) accesses 42 bytes.

84 bytes, I meant.

How do you arrive at that number? memcpy() does not define the behaviour
if the fields overlap.

So assuming the fields don't overlap, memcpy reads 42 bytes, and writes
42 different bytes, so accesses 84 bytes in total.

I must have been having a Duh moment. :(

Okay, so I'll turn it around: since the overlap of foo and bar is
not defined, we don't know that they occupy 42 distinct bytes each;
for example they might be offset by one byte from each other and
perhaps only 43 distinct bytes are accessed, 41 of them twice each.
The memcpy result is not defined for overlap, so we don't know
what the answer will be (fault for overlapping DMA perhaps), but
we can't say 84 bytes accessed for sure.

--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
.



Relevant Pages

  • Re: no sound with 4.8 & KDE
    ... > Okay, let's go back to the basics. ... I've checked that the port memory does not overlap ...
    (freebsd-questions)
  • Equation Spaces Out
    ... I inserted an equation in a PP page, and the words now overlap each other a ... it looked okay. ... How can I fix this? ... Prev by Date: ...
    (microsoft.public.powerpoint)
  • Re: How much is that in real money?
    ... Okay. ... Most of us don't cross our sevens. ... |overlap in intelligence between the ...
    (alt.usage.english)