home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1371 < prev    next >
Encoding:
Text File  |  1992-08-14  |  2.7 KB  |  66 lines

  1. 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
  2. From: jos@and.nl (Jos Horsmeier)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Adding garbage collection to C++
  5. Keywords: C, GC
  6. Message-ID: <92-08-070@comp.compilers>
  7. Date: 14 Aug 92 09:03:48 GMT
  8. References: <92-08-052@comp.compilers> <92-08-063@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: jos@and.nl (Jos Horsmeier)
  11. Organization: AND Software BV Rotterdam
  12. Lines: 51
  13. Approved: compilers@iecc.cambridge.ma.us
  14.  
  15. In article <92-08-063@comp.compilers> the moderator appends:
  16.  
  17. |[It is my impression that an ANSI C program is allowed to copy a pointer to
  18. |a long and later back to a pointer of the same type.  This sort of thing
  19. |makes it hard to find all the live data. -John]
  20.  
  21. True, all true, but you'd better not say these kind of things in
  22. comp.std.c, they'll nail your head to the floor for this ;-)
  23.  
  24. A pointer is _not_ an integral number, it's not even an _address_.
  25. Casting a pointer to and from an integral number type causes
  26. implementation defined behavior. The only exception to the rule is the
  27. number 0. [*] When casted to the appropriate pointer type, it yields a
  28. value somewhere in memory where no object will ever be stored. 
  29.  
  30. Since ANSI-C arrived, the concept of a pointer type has changed slightly.
  31. In the good old days when things such as ints, longs, pointers and the
  32. whole world could be stored in a 32 bit word, life was easy (boy, did I
  33. love those VAXes,) but more esoteric hardware architectures nowadays
  34. forbid such actions: pointers can be up to 256 bits wide, pointers can be
  35. some `magical' thingies, stored in a separate space in your machine etc.
  36. They are _not_ numbers. IMHO the concept of a pointer can be explained by
  37. looking upon them as a tuple: and address with some type information
  38. attached to it. As the standard states it:
  39.  
  40. ANSI-C 3.1.2.5 Types
  41.  
  42. [ ... ] A pointer type may be derived from a function type, an object
  43. type, or an incomplete type, called the referenced type. A pointer type
  44. describes an object whose value provides a reference to an entity of the
  45. referenced type. A pointer type derived from the referenced type T is
  46. sometimes called `pointer to T.' [ ... ]
  47.  
  48. Sorry if I sounded pedantic about it ...
  49.  
  50. kind regards,
  51.  
  52. Jos aka jos@and.nl
  53.  
  54. [*] The compiler provides the appropriate cast here, i.e. during runtime,
  55.     the following code is not conformant, i.e. the resulting value is
  56.     _not_ necessarily a NULL pointer value.
  57.  
  58.     char* p;
  59.     long  i;
  60.  
  61.     i= 0;
  62.     p= (char*)i;
  63. -- 
  64. Send compilers articles to compilers@iecc.cambridge.ma.us or
  65. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  66.