Common malloc/free practice violates ANSI standard ?

Conor P. Cahill cpcahil at virtech.UUCP
Mon Oct 16 09:24:46 AEST 1989


In article <1989Oct14.043811.669 at anucsd.oz>, bdm at anucsd.oz (Brendan McKay) writes:
> No doubt this problem was unintentional.  It could easily be fixed by a
> sentence reading something like
> "The pointer returned if the allocation succeeds is such that, if it is cast
> to a pointer to any type of object and then that pointer is cast to type
> void*, the original value is recovered."

That is the meaning of the "suitably aligned so that it may be
assigned to a pointer to any type of object and then used to access such an
object..." (Section 4.10.3).

An assignment of a void* pointer that is an invalid address for an OBJ*
will usually cause a core drop at the point of dereference and may cause
a core drop at the assignment.  It *should* not modify the value of the 
pointer.


-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list