home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / cplus / 2113 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.6 KB  |  38 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!titan!lpi!pkt
  3. From: pkt@lpi.liant.com (Scott Turner)
  4. Subject: Re: pointer comparisons
  5. Message-ID: <1993Jan25.151516.24326@lpi.liant.com>
  6. Sender: pkt@lpi (Scott Turner)
  7. Organization: Liant Software Corporation
  8. References: <1993Jan18.182452.15390@lpi.liant.com> <1993Jan20.173927.3061@vedge.com>
  9. Date: Mon, 25 Jan 1993 15:15:16 GMT
  10. Lines: 26
  11.  
  12. In article <1993Jan20.173927.3061@vedge.com>, hendrik@vedge.com (Hendrik Boom) writes:
  13. > In article <1993Jan11.190959.5305@lpi.liant.com>, pkt@lpi.liant.com (Scott Turner) writes:
  14. > > If we have objects of a type which requires no state, e.g.
  15. > >        struct B{} a, b;
  16. > > then in order for them to have distinct identities an implementation
  17. > > might allocate addresses that don't point to valid memory.  Again, no
  18. > > storage is required.
  19. > But if nonempty class C inherits from B, you have trouble comparing
  20. > pointers to B with pointers to C that have been converted to B,
  21. > unless you are careful that addresses of B's are outside of usable
  22. > memory.
  23.  
  24. The trouble is negligible almost all of the time.  For example,
  25.     struct C : B { int i; };
  26. an implementation could convert "pointer to C" to "pointer to B" using the
  27. same representation for both values.  If some pointers to B are pointing to
  28. invalid memory, the comparison will work out just right.
  29.  
  30. In unusual cases such as Johan Bengtsson's example, the compiler can "waste"
  31. a byte for the base class.
  32. --
  33. Prescott K. Turner, Jr.
  34. Liant Software Corp. (developers of LPI languages)
  35. 959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
  36. UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
  37.