Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!uunet!kddlab!ccut!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.co.jp (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <10828@riks.csl.sony.co.jp> Date: 13 Sep 89 03:49:43 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <1989Aug17.005548.745@twwells.com> <16022@vail.ICO.ISC.COM> <248@seti.inria.fr> <1010@m3.mfci.UUCP> <10973@smoke.BRL.MIL> <247@bbxeng.UUCP> <10985@smoke.BRL.MIL> Reply-To: diamond@ws.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 35 In article <247@bbxeng.UUCP> scott@bbxeng.UUCP (Scott-Engineering) writes: >>In other words - you cannot even *test* a pointer unless you are *sure* >>there is a valid address in it. I don't think so. In article <10985@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >There is no way a strictly conforming C program can create an invalid >pointer value, apart from free()ing a valid one that it got from malloc() >or realloc(). The moment an improper pointer value is created via >arithmetic operations, the program has violated the guarantees of the >Standard, and the implementation would be free to trap immediately. Another way to create a pointer that does not point to an object is to assign a NULL constant to it. A pointer variable containing a valid pointer value may be compared to a NULL constant. Scott-Engineering's posting implies these questions (among others): (1) if a pointer variable contains a NULL value, then may that pointer be compared to a NULL constant? (2) if a pointer variable contains a NULL value, then may that pointer be compared to a valid pointer value? Scott-Engineering's reading of the standard implied negative answers, which he finds hard to believe. (I still can't get a copy of the proposed standard and cannot form an opinion.) Mr. Gwyn, perhaps you could please post a better answer. -- -- Norman Diamond, Sony Corporation (diamond@ws.sony.junet) The above opinions are inherited by your machine's init process (pid 1), after being disowned and orphaned. However, if you see this at Waterloo or Anterior, then their administrators must have approved of these opinions.