home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / cplus / 1809 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.7 KB  |  52 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!utcsri!torn!nott!bnrgate!bcrka451!bcrki65!sjm
  3. From: sjm@bcrki65.bnr.ca (Stuart MacMartin)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec16.202711.22367@bcrka451.bnr.ca>
  6. Sender: 5E00 Corkstown News Server
  7. Organization: Bell-Northern Research Ltd., Ottawa, Canada
  8. References: <1992Dec9.133956.29659@lth.se> <1992Dec9.191606.5665@lucid.com> <BzCG7K.2sG@frumious.uucp>
  9. Date: Wed, 16 Dec 1992 20:27:11 GMT
  10. Lines: 40
  11.  
  12. In article <BzCG7K.2sG@frumious.uucp> pat@frumious.uucp (Patrick Smith) writes:
  13. >
  14. >jss@lucid.com (Jerry Schwarz) writes:
  15. >|And
  16. >|
  17. >|       if p < q is defined,  ptrcmp(p,q) < 0   <=>  p < q
  18. >
  19. >
  20. >This strikes me as nice to have, but not essential.
  21. >
  22. >On the other hand, this might be fairly cheap, given that
  23. >we're already insisting on
  24. >
  25. >   p == q   =>   ptrcmp(p,q) == 0
  26. >
  27.  
  28. It makes me nervous to disagree with you, but haven't we already 
  29. hammered to death the concept that p < q might be defined (but 
  30. not generate a total ordering) if some ps and qs are not in the
  31. same segment?  Or do the PC compilers only permit p < q for ps
  32. and qs in the same array?
  33.  
  34. Suppose we have a compiler that uses segment offset to determine
  35. if p < q but memory address to determine if p == q.
  36.  
  37. If p1 < q1 are near the end of segment 1,
  38.    p2 < q2 are near the beginning of segment 2
  39. and q1 == p2 (because they refer to the same memory location),
  40.  
  41. then
  42.    
  43.    p2 < q2 < p1 < q1   (because the segment is being ignored)
  44. but
  45.    p2 == q1   and   p2 != q2.
  46.  
  47. Stuart
  48. --
  49. : Stuart MacMartin                                    email: sjm@bnr.ca      :
  50. : Bell-Northern Research                              phone: (613) 763-5625  :
  51. : PO Box 3511, Stn C, Ottawa, K1Y-4H7, CANADA    Standard disclaimers apply. :
  52.