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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec15.162202.11231@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Dec8.173855.18153@meaddata.com> <1992Dec10.121935.19315@ucc.su.OZ.AU> <1992Dec11.230534.10499@microsoft.com>
  10. Date: Tue, 15 Dec 1992 16:22:02 GMT
  11. Lines: 46
  12.  
  13. In article <1992Dec11.230534.10499@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
  14. >In article <1992Dec10.121935.19315@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15. >|    The answer to this particular question is YES, they must
  16. >|compare equal according to the ARM. And I think this is a problem
  17. >|for OS design for the 386, for example, where the memory management
  18. >|kernel will just have to ignore the ARM.
  19. >
  20. >No more nor less than any other virtual memory OS that allows
  21. >multiply mapped pages.  Since there is no functionality in the
  22. >language requiring such multiply mapped pages, you only get in
  23. >this situation by invoking some system dependency, in which case
  24. >you are making use of implementation dependencies.  If you will,
  25. >a common C/C++ implementation defined extension to the language
  26. >is to allow the use of OS calls in order to map various regions
  27. >of memory to the same underlying page, allowing the same object
  28. >to be accessed via differing addresses.  Implementation defined,
  29. >no more nor less.
  30. >
  31.  
  32. But Jim, it is not implementation defined, it is required that 
  33. pointers to the same object compare equal. It is therefore
  34. legal to have a function:
  35.  
  36.     f(X* a, X*b) {
  37.     if(a==b) { /* special case, copy b object */ ... }
  38.     else *a+=*b;
  39.     }
  40.  
  41. where the += operation is destructive and wont work if a and b point
  42. to the same object. The above code is guarranteed in C++, but
  43. will fail on a suitably organised system. It is therefore not
  44. allowed to do this sort of memory mapping in C++ behind the scenes,
  45. which is what I'm concerned with...we actually want to.
  46.  
  47. So the question is really whether the requirement that pointers to
  48. the same object compare equal should be left implementation defined.
  49. Or perhaps more restrictions be made, like saying they must
  50. compare equal if one is assigned from another, but not otherwise.
  51.  
  52.  
  53.  
  54. -- 
  55. ;----------------------------------------------------------------------
  56.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  57.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  58. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  59.