home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1874 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.1 KB  |  71 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <9235622.26114@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU> <1992Dec16.201044.2968@microsoft.com> <1992Dec18.193554.18588@ucc.su.OZ.AU>
  9. Date: Mon, 21 Dec 1992 11:31:18 GMT
  10. Lines: 59
  11.  
  12. maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  13.  
  14. >jimad@microsoft.com (Jim Adcock) writes:
  15. >>maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  16. >>|But Jim, it is not implementation defined, it is required that 
  17. >>|pointers to the same object compare equal. It is therefore
  18. >>|legal to have a function:
  19. >>|
  20. >>|    f(X* a, X*b) {
  21. >>|    if(a==b) { /* special case, copy b object */ ... }
  22. >>|    else *a+=*b;
  23. >>|    }
  24. >>|
  25. >>However, if a strictly conforming implementation is presented with a 
  26. >>non-strictly conforming program, such as a program that calls OS
  27. >>virtual memory mapping adjustment routines, or programs that send
  28. >>pointers off the ends of arrays, or programs who don't properly point
  29. >>at objects that correspond to the types of objects they pretend to point
  30. >>at .... in all such cases all bets are off.  
  31. >>
  32. >    I know what you are saying but dont see it.
  33. >ARM p74:"two pointers to the same object compare equal".
  34. >Any program for which this is not true cannot be conforming,
  35. >neither strictly nor non-strictly, it is non-conforming, it is
  36. >not in fact a C++ program.
  37. >
  38. >    Or have I got this wrong?
  39.  
  40. I think you have got this wrong.
  41. Such a program might be neither strictly nor non-strictly conforming,
  42. but it is still a C++ program, at least in as far as that term is
  43. commonly used.
  44.  
  45. >    For this reason I think the ARM requirement is unworkable,
  46. >and must be modified. The rule should state that pointers
  47. >derived from the same object directly in the program must
  48. >compare equal. Pointers obtained from the OS need not follow
  49. >this rule, in that case it is implementation defined.
  50. >This is the case for pointers way off the end of an array:
  51. >it is implementation defined.
  52.  
  53. Remember that the ARM is a reference manual, not a standard.
  54. I believe that the ANSI C standard makes it clear that for
  55. programs that invoke code whose behaviour is "undefined", all
  56. bets are off. (The usual remark is that the system is allowed
  57. to spew frogs from the tape-drive, or something equally ridiculous,
  58. so desires). This is equally true of programs that invoke the
  59. operating system (other than by standard library functions
  60. defined in the ANSI C standard). Any guarantees about the
  61. behaviour of such programs must be made by a standard for that
  62. particular operating system, not by the ANSI C standard.
  63. The same will apply to the ANSI or ISO C++ standard, when
  64. it arrives.
  65.  
  66. -- 
  67. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  68. This .signature virus is a self-referential statement that is true - but 
  69. you will only be able to consistently believe it if you copy it to your own
  70. .signature file!
  71.