Re: Can I do ANYTHING on allocated memory?
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Sat, 13 Jan 2007 19:18:54 -0000
"Harald van D?k" <truedfx@xxxxxxxxx> wrote in message
Malcolm
It doesn't even rely on that. You can safely convert any result fromYou are confusing what will happen on any current implementation with what
malloc to and from any non-function pointer type. The only time pointer
casts can lose information (or worse) is if the pointer is not properly
aligned, but the pointer is the result from a call to malloc, so it
must be properly aligned.
is guaranteed by the standard.
*The standard is a bit underspecified regarding pointer conversions, but
*does clearly address this part in 6.3.2.3p7: "A pointer to an object or
*incomplete type may be converted to a pointer to a different object or
*incomplete type. If the resulting pointer is not correctly aligned57)
*for the pointed-to type, the behavior is unde?ned. Otherwise, when
*converted back again, the result shall compare equal to the original
*pointer."
You are actaully correct, because of that that phrase "correctly aligned".
As you say, it is a bit under-specified. At the moment all pointers consist
of hardware (1)address plus, occasionally, alignment bits to implement
sub-hardware byte chars. That might change because of technical developments
in the future, though I couldn't think of an obvious scenario.
(1) for the pedants, sometimes a translated hardware address.
.
- References:
- Can I do ANYTHING on allocated memory?
- From: Sourcerer
- Re: Can I do ANYTHING on allocated memory?
- From: Richard Tobin
- Re: Can I do ANYTHING on allocated memory?
- From: Malcolm McLean
- Re: Can I do ANYTHING on allocated memory?
- From: Richard Tobin
- Re: Can I do ANYTHING on allocated memory?
- From: Harald van Dijk
- Re: Can I do ANYTHING on allocated memory?
- From: Malcolm McLean
- Re: Can I do ANYTHING on allocated memory?
- From: Harald van Dijk
- Can I do ANYTHING on allocated memory?
- Prev by Date: Isn't it time there was a standard align statement?
- Next by Date: Re: Draft Secure C
- Previous by thread: Re: Can I do ANYTHING on allocated memory?
- Next by thread: Re: Can I do ANYTHING on allocated memory?
- Index(es):
Relevant Pages
|