home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / cplus / 1158 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.2 KB  |  38 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Sep11.190134.4283@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Sep10.162906.14398@genghis.borland.com> <4950@holden.lulea.trab.se>
  8. Date: Fri, 11 Sep 1992 19:01:34 GMT
  9. Lines: 27
  10.  
  11. jbn@lulea.trab.se (Johan Bengtsson) writes:
  12.  
  13. |pete@genghis.borland.com (Pete Becker) writes:
  14.  
  15. |:     0x0000:0x0010
  16. |:     0x0001:0x0000
  17. |: 
  18. |: These two addresses refer to the same memory location.  Converting them to
  19. |: longs in the most obvious way produces these two values:
  20. |: 
  21. |:     0x00000010
  22. |:     0x00010000
  23.  
  24. |But can this really happen, if the rule "pointer arithmetic only
  25. |within an array" is adhered to?  Shouldn't all pointers within an
  26. |array be based on the same segment?
  27.  
  28.  
  29. If you do non-normalized pointer arithmetic, the offset portion could
  30. be greater than 15 and still point within the array.  This causes no
  31. problems for the hardware, which doesn't care whether pointers are
  32. normalized.  The compiler must still arrange for pointer comparisons
  33. to come out right, such as by normalizing them first.
  34. -- 
  35.  
  36. Steve Clamage, TauMetric Corp, steve@taumet.com
  37. Vice Chair, ANSI C++ Committee, X3J16
  38.