🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #732

Re: commom malloc/free practice breaks standard - author strikes back

#732
From: David Adrien Tanguay
Date: Fri, 20 Oct 1989 10:44
24 lines
1594 bytes
In article <992@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>I, like many others, rely on the gurus in comp.lang.c for much valuable
>information.  Can somebody quote chapter and verse to show that the
>standard does require the series of casts
>
>     void * ->  OBJ *  ->  void *
>
>to yield the original pointer?

For a general pointer this is not the case, but the argument is about
pointers returned by malloc. From section 4.10.3 "Memory management functions":

	The pointer returned if the allocation succeeds is suitably aligned
	so that it may be assigned to a pointer to any type of object and
	then used to access such an object or an array of such objects in
	the space allocated (until the space is explicitly freed or
	reallocated). Each such allocation shall yield a pointer to an
	object disjoint from any other object. The pointer returned points
	to the start (lowest byte address) of the allocated space.

I don't see anything there (or anywhere in 4.10.3.*) that asserts the above
series of casts.

David Tanguay
Technical Details
Message-ID: <30537@watmath.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!watmath!datanguay
References: <1989Oct16.111059.3840@anucsd.oz> <992@cirrusl.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!watmath!datanguay
From: datanguay@watmath.waterloo.edu (David Adrien Tanguay)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: commom malloc/free practice breaks standard - author strikes back
Message-ID: <30537@watmath.waterloo.edu>
Date: 20 Oct 89 10:44:30 GMT
References: <1989Oct16.111059.3840@anucsd.oz> <992@cirrusl.UUCP>
Reply-To: datanguay@watmath.waterloo.edu (David Adrien Tanguay)
Organization: U. of Waterloo, Ontario
Lines: 24