home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
- From: jss@lucid.com (Jerry Schwarz)
- Subject: Re: Pointer comparisons
- Message-ID: <1992Dec23.182456.17185@lucid.com>
- Sender: usenet@lucid.com
- Reply-To: jss@lucid.com (Jerry Schwarz)
- Organization: Lucid, Inc.
- References: <1992Dec16.202711.22367@bcrka451.bnr.ca> <BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec19.001851.22116@microsoft.com>
- Date: Wed, 23 Dec 92 18:24:56 GMT
- Lines: 38
-
- Jim Adcock is advocating that under some circumstances it
- is ok for a compiler to put two A objects at the same location.
-
- His example is
-
- |> class A {};
- |>
- |> class B : public A
- |> {
- |> public:
- |> A a;
- |> };
- |>
-
- B b ;
-
- Where he claims it is ok for b.a and (B&)a to compare equal.
-
- I don't agree, but I'm wondering exactly what criteria he is applying.
- Does anything go for A's. E.g.
-
- void f() {
- A a1, a2 ; // can &a1==&a2
- ... ;
- }
-
- Is it only ok for "empty" classes? How about
-
- struct D { int i; int j ; } ;
-
- void f() {
- D d1, d2 ;
- ... d1.i ... d2.j ... // never use d1.j or d2.i
- }
-
- Can &d1==&d2.
-
- -- Jerry Schwarz
-