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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec16.201044.2968@microsoft.com>
  6. Date: 16 Dec 92 20:10:44 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec10.121935.19315@ucc.su.OZ.AU> <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU>
  9. Lines: 27
  10.  
  11. In article <1992Dec15.162202.11231@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  12. |But Jim, it is not implementation defined, it is required that 
  13. |pointers to the same object compare equal. It is therefore
  14. |legal to have a function:
  15. |
  16. |    f(X* a, X*b) {
  17. |    if(a==b) { /* special case, copy b object */ ... }
  18. |    else *a+=*b;
  19. |    }
  20. |
  21. |where the += operation is destructive and wont work if a and b point
  22. |to the same object. The above code is guarranteed in C++, but
  23. |will fail on a suitably organised system. It is therefore not
  24. |allowed to do this sort of memory mapping in C++ behind the scenes,
  25. |which is what I'm concerned with...we actually want to.
  26.  
  27. If a strictly conforming implementation is presented with a strictly
  28. conforming program, then the above works subject to some additional 
  29. constraints, such as a and b refering to disjoint objects.
  30.  
  31. However, if a strictly conforming implementation is presented with a 
  32. non-strictly conforming program, such as a program that calls OS
  33. virtual memory mapping adjustment routines, or programs that send
  34. pointers off the ends of arrays, or programs who don't properly point
  35. at objects that correspond to the types of objects they pretend to point
  36. at .... in all such cases all bets are off.  
  37.  
  38.