Re: pointer conversion




"Charlton Wilbur" <cwilbur@xxxxxxxxxxxxxx> wrote in message news:87abs7wu2c.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx
"M" == Malcolm McLean <regniztar@xxxxxxxxxxxxxx> writes:

M> You will be OK. char is always 1 byte. So casting an arbitrary
M> pointer to a char *, adding an exact multiple of the size of
M> the original type, and casting back is guaranteed to preserve
M> alignment.

I am not so sure about that; would you care to cite C&V, please, if
you claim that it's guaranteed by the standard?

Arrays have to be contiguous in memory. No padding bytes may be inserted between items.
The rest follows from that.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

.



Relevant Pages

  • Re: pointer conversion
    ... M> pointer to a char *, adding an exact multiple of the size of ... M> the original type, and casting back is guaranteed to preserve ... If the original pointer points at an actual object of its ...
    (comp.lang.c)
  • Re: Lawful Stupid
    ... >> Casting a spell with an alignment descriptor does not have any impact ... Casting an aligned spell is an aligned act. ... aligned actions. ...
    (rec.games.frp.dnd)
  • Re: pointer conversion
    ... Eric Sosman wrote: ... M> the original type, and casting back is guaranteed to preserve ... If the original pointer points at an actual object of its ... alignment", not that it's legal. ...
    (comp.lang.c)
  • Re: Lawful Stupid
    ... > casting a Good spell has no effect on a caster's alignment ("has no ... "proof by contradiction" is meaningless. ...
    (rec.games.frp.dnd)
  • Re: Lawful Stupid
    ... result in an alignment change, it should still count as a violation of evil codes of conduct. ... It is what you cast the spell FOR that determines that. ... This is how casting a spell is NOT like channeling positive power such as is used in turning undead, which WOULD violate your standards regardless of context. ...
    (rec.games.frp.dnd)