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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Pointer Comparisons
  5. Message-ID: <1992Dec24.203726.26481@microsoft.com>
  6. Date: 24 Dec 92 20:37:26 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec20.000341.6417@ucc.su.OZ.AU> <5451@holden.lulea.trab.se> <1992Dec23.172735.15352@ucc.su.OZ.AU>
  9. Lines: 38
  10.  
  11. In article <1992Dec23.172735.15352@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  12. |ARM requires non-zero length objects doesnt it?
  13.  
  14. No, ARM does not make such a requirement.  ARM requires sizeof(Ob) to
  15. be greater than zero.  And ARM requires new Ob to return a distinct address.
  16. But this is not the same as requiring Ob to have non-zero length.
  17. The basic underlying requirement is that the space that Ob takes as an
  18. element of an array be greater than zero, so that pointers to different
  19. elements in the array have different values.  This can be achieved for
  20. zero-length objects by requiring them to have at least one-byte trailing
  21. alignment padding when placed in arrays.  When used as a member of a structure,
  22. the object wouldn't necessarily have the same padding and alignment
  23. requirements.  For example ARM *explicitly* makes no requirement of
  24. implementations in the following example:
  25.  
  26. class A {};
  27.  
  28. class B
  29. {
  30. public:
  31.     A a1;
  32. public:
  33.     A a2;
  34. };
  35.  
  36. main()
  37. {
  38.     B b;
  39.     A* p1 = &(b.a1);
  40.     A* p2 = &(b.a2);
  41.  
  42.     if (p1 == p2)
  43.         cout << "its undefined according to ARM!\n";
  44.     else
  45.         cout << "boring case -- but still undefined behavior!\n";
  46.  
  47.     return 0;
  48. }
  49.