From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,85c4b961f840b5ab X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!nwrdny03.gnilink.net.POSTED!0f19ed38!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: Subject: Re: Zero length Objects X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: <2oUEc.2$S77.1@nwrdny03.gnilink.net> Date: Thu, 01 Jul 2004 13:32:46 GMT NNTP-Posting-Host: 141.154.250.122 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1088688766 141.154.250.122 (Thu, 01 Jul 2004 09:32:46 EDT) NNTP-Posting-Date: Thu, 01 Jul 2004 09:32:46 EDT Xref: g2news1.google.com comp.lang.ada:2023 Date: 2004-07-01T13:32:46+00:00 List-Id: "Brian May" wrote in message news:sa41xjwy2nv.fsf@snoopy.apana.org.au... > >>>>> "Frank" == Frank J Lhota writes: > > Frank> No object is really of zero length. The reason is that > Frank> every object should have a unique address. Therefore, most > Frank> Ada compilers will allocate at least one storage element to > Frank> each object, in order to insure that if we declare > > Frank> A, B : Empty_Type; > > Frank> then A and B do not both refer to the same location. > > Is there any reason every object needs to have a unique address? The issue is that if A and B share an address, then they are basically aliases of each other, for no subprogram could distinguish between them. The programmer, however, is declaring A and B as two separate objects, so making them aliases would be a violation of the author's intentions. AFAIK C++ takes the same approach. In fact, the first C++ tutorial I went through (the one that came with Borland's groundbreaking BC++ compiler for DOS and Windows) included a code sample that was something like this: class CEmpty {}; ... CEmpty a, b; The tutorial recommended generating an assembly listing for this code to note that even though CEmpty is empty, a and b are allocated at separate addresses, and that this is important because operations should be able to distinguish a and b. I tried this with GCC and MSVC. Not only did both compilers assign a and b separate addresses, but for both of these compilers ( sizeof( CEmpty ) == 1 ) && ( sizeof( a ) == 1 )