Xref: utzoo comp.std.c:1823 comp.lang.c:22873 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Common malloc/free practice violates ANSI standard ? Message-ID: <1279@virtech.UUCP> Date: 15 Oct 89 23:24:46 GMT References: <1989Oct14.043811.669@anucsd.oz> Organization: Virtual Technologies Inc Lines: 22 In article <1989Oct14.043811.669@anucsd.oz>, bdm@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 | +-----------------------------------------------------------------------+