home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!wupost!cs.utexas.edu!sun-barr!rutgers!faatcrl!iecc!compilers-sender
- From: jos@and.nl (Jos Horsmeier)
- Newsgroups: comp.compilers
- Subject: Re: Adding garbage collection to C++
- Keywords: C, GC
- Message-ID: <92-08-070@comp.compilers>
- Date: 14 Aug 92 09:03:48 GMT
- References: <92-08-052@comp.compilers> <92-08-063@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: jos@and.nl (Jos Horsmeier)
- Organization: AND Software BV Rotterdam
- Lines: 51
- Approved: compilers@iecc.cambridge.ma.us
-
- In article <92-08-063@comp.compilers> the moderator appends:
-
- |[It is my impression that an ANSI C program is allowed to copy a pointer to
- |a long and later back to a pointer of the same type. This sort of thing
- |makes it hard to find all the live data. -John]
-
- True, all true, but you'd better not say these kind of things in
- comp.std.c, they'll nail your head to the floor for this ;-)
-
- A pointer is _not_ an integral number, it's not even an _address_.
- Casting a pointer to and from an integral number type causes
- implementation defined behavior. The only exception to the rule is the
- number 0. [*] When casted to the appropriate pointer type, it yields a
- value somewhere in memory where no object will ever be stored.
-
- Since ANSI-C arrived, the concept of a pointer type has changed slightly.
- In the good old days when things such as ints, longs, pointers and the
- whole world could be stored in a 32 bit word, life was easy (boy, did I
- love those VAXes,) but more esoteric hardware architectures nowadays
- forbid such actions: pointers can be up to 256 bits wide, pointers can be
- some `magical' thingies, stored in a separate space in your machine etc.
- They are _not_ numbers. IMHO the concept of a pointer can be explained by
- looking upon them as a tuple: and address with some type information
- attached to it. As the standard states it:
-
- ANSI-C 3.1.2.5 Types
-
- [ ... ] A pointer type may be derived from a function type, an object
- type, or an incomplete type, called the referenced type. A pointer type
- describes an object whose value provides a reference to an entity of the
- referenced type. A pointer type derived from the referenced type T is
- sometimes called `pointer to T.' [ ... ]
-
- Sorry if I sounded pedantic about it ...
-
- kind regards,
-
- Jos aka jos@and.nl
-
- [*] The compiler provides the appropriate cast here, i.e. during runtime,
- the following code is not conformant, i.e. the resulting value is
- _not_ necessarily a NULL pointer value.
-
- char* p;
- long i;
-
- i= 0;
- p= (char*)i;
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-