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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <BzG1Jx.JH@frumious.uucp>
  6. Date: Fri, 18 Dec 1992 07:16:44 GMT
  7. Reply-To: uunet.ca!frumious!pat
  8. References: <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU> <1992Dec17.150914.2783@lpi.liant.com>
  9. Organization: None
  10. Lines: 44
  11.  
  12. pkt@lpi.liant.com (Scott Turner) writes:
  13. |In article <1992Dec15.162202.11231@ucc.su.OZ.AU> John (Max) Skaller writes:
  14. |It makes me uneasy, but I think Jim Adcock is correct: an implementation
  15. |can define an extension, such as memory mapping, which overrides the usual
  16. |execution time rules of C/C++, including the rule that pointers to the same
  17. |object compare equal.  The rule that 1+1==2 would likewise be subject to
  18. |"extension".
  19.  
  20. For C, this is my impression also.  Although I find the terminology
  21. unfortunate; it's unsettling to think that a conforming implementation
  22. could compile and run a conforming program - which could then compute
  23. 1+1 and get 3.
  24.  
  25. Has X3J16 adopted similar notions of conformity?
  26.  
  27.  
  28. |Nevertheless, the C standard implies that the onus is on the invoker of memory 
  29. |mapping to be aware of libraries and other code which may rely on the usual
  30. |execution time rules of C/C++, such as the rule that pointers to the same
  31. |object compare equal.  If we don't want libraries to make that assumption,
  32. |then John (Max) Skaller is also correct to say
  33. |
  34. |> So the question is really whether the requirement that pointers to
  35. |> the same object compare equal should be left implementation defined.
  36.  
  37. Here I would disagree.  I think the question is whether, if the C++
  38. standard adopts the same notions of conformity as the C standard,
  39. pointers to the same object should be required to compare equal
  40. in a conforming program.
  41.  
  42. And the answer is _no_.  I hope this requirement would exist for
  43. _strictly_ conforming programs.  And it might be _reasonable_ to
  44. expect it to hold in conforming programs.  But in a conforming 
  45. program which depends on behaviour undefined or unspecified by
  46. the standard, none of the rules apply, so the standard doesn't
  47. actually _require_ anything.  (It's not clear to me whether all
  48. rules disappear if a program fails to be strictly programming
  49. because it depends on implementation-defined behaviour, but it
  50. doesn't depend on any undefined or unspecified behaviour.)
  51.  
  52. -- 
  53. Patrick Smith
  54. uunet.ca!frumious!pat
  55. pat%frumious.uucp@uunet.ca
  56.