home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1953 < prev    next >
Encoding:
Text File  |  1993-01-02  |  2.9 KB  |  65 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!lpi!pkt
  3. From: pkt@lpi.liant.com (Scott Turner)
  4. Subject: Re: pointer comparisons
  5. Message-ID: <1993Jan2.211538.11320@lpi.liant.com>
  6. Organization: Liant Software Corporation
  7. Distribution: usa
  8. Date: Sat, 2 Jan 1993 21:15:38 GMT
  9. Lines: 54
  10.  
  11. In article <9300300.29900@mulga.cs.mu.OZ.AU> (Fergus James HENDERSON) 
  12. writes:
  13. > pkt@lpi.liant.com (Scott Turner) writes:
  14. > > But note that section 1.3 of the working paper (The C++ Memory Model) says:
  15. > >
  16. > >           The constructs in a C++ program create, refer to, access, and
  17. > >           manipulate objects in memory.  Each object (except bit-fields)
  18. > >        occupies one or more contiguous bytes.
  19.  
  20. > > How much freedom does it leave a compiler to optimize away
  21. > > an object's bytes (by application of the "as if" rule, etc.)?
  22. > > I think a good deal of freedom, [...]
  23. > Perhaps, but
  24. >   "The _sizeof_ operator yields the size, in bytes, of its operand".
  25. > I think that it would be a very brave compiler-writer whose compiler
  26. > made it unreliable to write() an object and read() it in again, because
  27. >   read(fd, &object, sizeof object);
  28. > randomly trashes the bytes past the end of the object.
  29.  
  30. Yes, that's a relevant point.  But it does not mean that 1.3 restricts
  31. the compiler's ability to optimize, because 5.3.2 already says that
  32. sizeof yields a result of at least 1.  So I'll hold to my conclusion
  33. that the above excerpt from 1.3 belongs in the C++ standard.
  34.  
  35. > However, the murkiness of the concepts involved in "object identity" appears
  36. > to make it very difficult or impossible to provide such guarantees
  37. [about pointer comparison].
  38.  
  39. On the contrary, this lengthy discussion has regularly debated how pointer 
  40. comparison should work in relation to whether the pointers refer to the
  41. same object.  Despite murkiness in the ARM, our shared concept of object
  42. identity has held up.  I can think of only one example in which there was
  43. disagreement about object identity, and in that case it seemed to be 
  44. cleared up quickly.
  45.  
  46. > My own metaphysical perspective is that subobjects are
  47. > by definition not objects in their own right
  48.  
  49. My perspective, that subobjects are objects, has stood up to 4 years of
  50. working with the C++ reference manual and working paper.  It fits in better
  51. with the common application of the prefix "sub".  For example, a subset is
  52. so called not because it belongs to a set, but because it _is_ a set 
  53. subordinate to another set.  If a subset were not properly a set, then
  54. it never would have been called a subset.  Likewise "subobject" would be
  55. a poor term if it did not refer to an object.
  56.  
  57. Furthermore, the ARM calls subobjects objects.  Look toward the end of 
  58. 10.1.1 (p. 206) "the same object representing the base class".
  59. --
  60. Prescott K. Turner, Jr.
  61. Liant Software Corp. (developers of LPI languages)
  62. 959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
  63. UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
  64.