home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3260 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  1.6 KB

  1. Path: sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.std.c
  4. Subject: Re: pointer comparison
  5. Message-ID: <1992Dec23.165636.10674@thunder.mcrcim.mcgill.edu>
  6. Date: 23 Dec 92 16:56:36 GMT
  7. References: <18221@autodesk.COM>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 32
  10.  
  11. Well, it's been a couple of days, and I'm about to leave, and *nobody*
  12. has replied (as far as our news server knows), so I'll stick my neck
  13. out in public again....
  14.  
  15. In article <18221@autodesk.COM>, larsn@Autodesk.COM (Lars Nyman) writes:
  16.  
  17. > I *think* there is language in the standard that says something to
  18. > the effect that comparisons of pointers to two objects that are NOT
  19. > members of the same aggregate or union object is undefined (with one
  20. > exception - one or both pointers pointing past the last object of an
  21. > array).
  22.  
  23. The actual situation is close.  For the time being, let us consider
  24. pointers pointing one element past the end of an array as actually
  25. pointing into that array.  With that proviso, pointer comparison using
  26. <, <=, >, or >= is undefined when the two pointers don't point into the
  27. same object.
  28.  
  29. Pointer comparison using == or != is always well-defined, and the
  30. pointers compare equal exactly when they point to the same thing (and
  31. != is the complement of ==).
  32.  
  33. > So, if I have two different objects of same type, and they are not in
  34. > the same array or aggregate, the result of comparing pointers to them
  35. > is undefined !!???
  36.  
  37. Yes, except with == or !=.
  38.  
  39.                     der Mouse
  40.  
  41.                 mouse@larry.mcrcim.mcgill.edu
  42.