home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1890 < prev    next >
Encoding:
Text File  |  1992-12-22  |  3.2 KB  |  84 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: <1992Dec22.002957.25597@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: <1992Dec16.201044.2968@microsoft.com> <1992Dec18.193554.18588@ucc.su.OZ.AU> <1gtblgINN72@darkstar.UCSC.EDU>
  10. Date: Tue, 22 Dec 1992 00:29:57 GMT
  11. Lines: 71
  12.  
  13. In article <1gtblgINN72@darkstar.UCSC.EDU> daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
  14. >
  15. >>    For this reason I think the ARM requirement is unworkable,
  16. >>and must be modified. The rule should state that pointers
  17. >>derived from the same object directly in the program must
  18. >>compare equal. Pointers obtained from the OS need not follow
  19. >>this rule, in that case it is implementation defined.
  20. >
  21. >Neither the C standard nor the C++ standard discusses any OS.
  22. >(As far as I recall.)
  23.  
  24.     Precisely, nor should they, instead, they ought discuss
  25. the conditions under which the rule is true, otherwise
  26. it is implementation defined.
  27. >
  28. >A call to the operating system should be viewed as
  29. >a call to an extension supplied by the language provider. 
  30. >A program that uses an extension can be conforming but
  31. >not strictly conforming, as per the X3J16 definitions. 
  32.  
  33.     Sure. But my interpretation of the p==q rule
  34. is that any implementation in which it isnt true
  35. is *non*-conforming. That is, there is no scope in the rule
  36. for non-strict conformance.
  37.  
  38. >
  39. >Thus, I think a better rule is:
  40. >    ``In a strictly conforming program, two pointers
  41. >    to the same object compare equal.''
  42. >Thus, this property need not be true in any program that
  43. >calls the operating system.
  44.  
  45.     That is in the spirit of what I wanted, but I'm
  46. not sure if a standard can say it in those words. Besides,
  47. I wanted to be more explicit: even if I do an operting
  48. system call somewhere, I want the system
  49. to guarrantee
  50.  
  51.     T* p=new T;
  52.     T* q=p;
  53.     if(!(p==q))cout<"Non conforming program";
  54.  
  55. But I want that
  56.  
  57.     q=alias(p); // OS call to alias pointer
  58.     if(!(p==q))cout<"Not a strictly conforming program";
  59.  
  60. (Given that p and q point to the same object after aliasing).
  61. In particular I dont want the above code to render the whole
  62. program non-conforming.    
  63. >
  64. >I think actually that ramifications of multiple inheritance 
  65. >and multiple object-addresses should be explicitly addressed
  66. >in the rule, such as by saying that a pointer to a base-class
  67. >subobject is not a pointer to the same object as a pointer
  68. >to the most-derived class object.
  69. >
  70.     The rule only applies when p and q are the same type.
  71. If a conversion from a derived to base type occurs a comparison
  72. would quite correctly yield 1 if the base subobject was a
  73. sub-object of the complete object.
  74.  
  75.     The other issue is whether empty subobjects are generated
  76. or not, if they can be, pointers to different subobjects of the
  77. same type might compare equal.
  78.  
  79. -- 
  80. ;----------------------------------------------------------------------
  81.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  82.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  83. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  84.