Common malloc/free practice violates ANSI standard ?

T. William Wells bill at twwells.com
Mon Oct 30 21:41:53 AEST 1989


In article <1328 at crdos1.crd.ge.COM> davidsen at crdos1.UUCP (bill davidsen) writes:
: In article <1989Oct19.101306.16791 at twwells.com>, bill at twwells.com (T. William Wells) writes:
: |  The standard requires that casting from (void*) to (OBJ*) and back
: |  give pointers that compare equal and point to the same object.
: |  Free will have no problems with it.
:
:   I think you said this backward (or you misread it). You can cast *to*
: a void pointer and *back* without loss of information, but not the
: other way 'round. On machines which require allignment at all,
: assignment to a pointer to an alligned type may result in loss of
: information via rounding.

My error. I should have said, somewhere, that all this is
dependent on knowing that the pointer really can point to an OBJ,
as in the result of a malloc.

I hope that my later articles have adequately corrected this
mistake.

Sorry I wasn't more careful.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.std.c mailing list