Re: void * in ANSC
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: Mon, 4 Feb 2008 22:38:13 +0000 (UTC)
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
.
- References:
- void * in ANSC
- From: Mark Jiao
- Re: void * in ANSC
- From: Army1987
- Re: void * in ANSC
- From: Walter Roberson
- Re: void * in ANSC
- From: Harald van Dijk
- void * in ANSC
- Prev by Date: Re: void * in ANSC
- Next by Date: Re: When to check the return value of malloc
- Previous by thread: Re: void * in ANSC
- Next by thread: Re: void * in ANSC
- Index(es):
Relevant Pages
|