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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Zero length Objects Date: Thu, 1 Jul 2004 16:26:23 +0100 Message-ID: <2kioovF2rj2qU1@uni-berlin.de> References: <2kh2leF2ct4hU1@uni-berlin.de> X-Trace: news.uni-berlin.de p60BL5/A2DrxAxcZX6+udwj1nU7ygxd0B2hEDuGbOBuGIba50= 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 Xref: g2news1.google.com comp.lang.ada:2030 Date: 2004-07-01T16:26:23+01:00 List-Id: "Xenos" wrote in message news:cc15on$nsc5@cui1.lmms.lmco.com... > C++ has a similar rule that says an object cannot be zero bytes in > size, but it does says that an empty (no data members) base class > may be zero size within the inherited class. Does Ada have a > similar rule to this? As far as I am aware, the Ada standard permits types, subtypes, and objects of zero size. I think that X'Size must return 0 if it has been set to 0 (by a representation clause) for any subtype or object X, but there is nothing in the standard to prevent objects of zero size being allocated more than zero bits when they are allocated in memory (and I gather this is what many compilers actually do). > Meaning if I create a null record and derive a another record from it, > will the null record take up zero space within the derived record? Again, I don't think the standard mandates exactly what the comnpiler does by default. However, of course, you can always /tell/ the compiler where and how big a member should be (in a record representation clause). Oddly, you can specify something like: Empty_Member at 0 range 1..0; in order to tell the compiler that Empty_Member is to take up no space in the record. > Sorry, if my terminology isn't exact for Ada, I a little new to the 95 > standard. I have the same problem with C++ :-) -- Nick Roberts