Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!munnari.oz.au!csc!csc3!anucsd!bdm From: bdm@anucsd.oz (Brendan McKay) Newsgroups: comp.std.c Subject: malloc/free practice - more from the author Message-ID: <1989Oct17.033415.16036@anucsd.oz> Date: 17 Oct 89 03:34:15 GMT Organization: Comp Sci, Australian National Uni, Canberra Lines: 27 Oops. I shouldn't have replied from home without my copy of the standard. >> (D) Doug Gwyn >> No, we didn't -- any valid pointer can be converted to a pointer that >> has less strict alignment and back, so that the result compares equal >> to the original pointer, > I can only find this rule for OBJ* -> void* -> OBJ* and OBJ* -> char* -> OBJ*. > Am I missing a section? Yes I was: Section 3.4.4. Apologies to Doug. =========================================================================== Most of you people don't understand my point. You keep repeating that malloc() is supposed to return a value with all-the-alignment-requirements- of-any-type and that a subsequent cast to OBJ* won't change the-underlying- address-or-whatever. If I was implementing malloc() [I'm not, by the way.], I wouldn't do it any other way. All I'm arguing is that the standard does NOT require that. The only alignment requirement made for the value of malloc() is THAT IT IS SUITABLE FOR USE *AFTER CASTING*. If you don't believe me, read the standard again. Yes, this is maybe just an exercise in pedantry. Well-written standards should survive such exercises, though. Brendan McKay. bdm@anucsd.oz or bdm@anucsd.oz.au