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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!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: <1992Dec20.012551.11306@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> <KANZE.92Dec10171114@slsvdnt.us-es.sel.de>
  10. Date: Sun, 20 Dec 1992 01:25:51 GMT
  11. Lines: 76
  12.  
  13. In article <KANZE.92Dec10171114@slsvdnt.us-es.sel.de> kanze@us-es.sel.de (James Kanze) writes:
  14. >In article <1992Dec10.121935.19315@ucc.su.OZ.AU>
  15. >maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  16. >|> >different addresses, but are pointing to the same object, must they
  17. >|> >compare equal? 
  18. >
  19. >|>     The answer to this particular question is YES, they must
  20. >|> compare equal according to the ARM. And I think this is a problem
  21. >|> for OS design for the 386, for example, where the memory management
  22. >|> kernel will just have to ignore the ARM.
  23. >
  24. >As it should.  The ARM (and the upcoming ANSI standard) can only
  25. >address what happens in the context of C++, not what happens to the
  26. >pointer once the OS gets its hands on it.
  27.  
  28.     No, this is not true IMHO. The ARM can and does explicitly
  29. or implicitly say "implementation defined" where it means that.
  30. When the ARM says "so and so will be the case" then it must
  31. always be the case.
  32.  
  33. >
  34. >In a similar vein, for example, the ANSI C standard states that the
  35. >NULL pointer will not point to any object.  But all 8086 programmers
  36. >know that if you compile with 32 bit pointers, it actually points to
  37. >the interrupt vector table!  However, this is *not* an object defined
  38. >in any C program, so this is perfectly legal.  (If it wasn't, you
  39. >couldn't have C on machines without protected memory.)
  40.  
  41.     This is just your interpretation that "object"
  42. means "object created by the program". It should not
  43. be up to your interpretation IMHO.
  44.  
  45. >
  46. >In the same way, I would understand the ARM to be saying that all
  47. >pointers generated by a correct program to point to any object defined
  48. >(including a dynamic definition by new) in C++ will compare equal.  If
  49. >you give the pointer to the OS, and it gives it back to you, then any
  50. >guarantees must be made by the OS, and not the C++ language.
  51.  
  52.     I agree. But that is not the case. The ARM says different.
  53. It absolutely requires pointers to the same object to compare
  54. equal, without qualification. The system MUST ensure this
  55. to classify as conforming. Since we both agree this is undesirable,
  56. as it would make conforming translators impossible to write,
  57. we have to change the ARM (well, the standard) to say what we
  58. actually mean.
  59.  
  60. >|>     If we dropped this requirement, however, there would
  61. >|> be no easy way to identify objects.
  62. >
  63. >Once you leave the safe and easy world of your program, there is no
  64. >easy way to identify objects.  C++ doesn't address such problems as
  65. >persistance, transportability or shared memory.
  66.  
  67.     It doesnt have to if it leaves enough things
  68. "implementation defined". If something is "ARM defined",
  69. it isnt implementation defined, and the translator MUST
  70. do what the ARM says to be ARM-conforming. Similarly,
  71. if it is one of those things the translator CANT be
  72. responsible for, a strictly conforming program must
  73. follow those rules. (E.g. not pointing more than 1 past
  74. the end of an array).
  75.  
  76.     The problem then is that it isnt possible
  77. to write a C++ program to do 386 memory management
  78. with the current rule for == for pointers.
  79. Not even a non-stricty conforming one, because there is no
  80. scope for implementation defined variation.
  81.  
  82.     IMHO there should be.
  83.  
  84. -- 
  85. ;----------------------------------------------------------------------
  86.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  87.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  88. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  89.