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,58331d88725b914e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: for Object_Size use 0 Date: 13 Apr 2005 11:51:46 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1113407506 19396 192.74.137.71 (13 Apr 2005 15:51:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 13 Apr 2005 15:51:46 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:10427 Date: 2005-04-13T11:51:46-04:00 List-Id: "Robert C. Leif" writes: > I specifically need to know if it is possible to create a zero sized > type in Ada 95 or the updated standard, which is to be released in the near > future. For a discrete type, Size can be zero. So in your example: type Empty_Type is (Empty); Empty_Type'Size must be zero (if there is no Size clause). This follows from RM-13.3(55). The same is true of "subtype S is Integer range 0..0;" -- S'Size = 0 by default. See also para 55.b in the AARM. An implementation must support "for Empty_Type'Size use 0;", but that's not necessary -- it must be 0 by default. I think GNAT does this wrong. That's a bug in GNAT, but I don't think they consider it important enough to fix. 'Object_Size is a GNAT-specific attribute, so its semantics are defined by AdaCore. AI-319 proposed to add this attribute to the language, but I believe it was not approved for Ada 2005. There are no requirements on Size for record types. It would be nice if compilers could avoid storing the discriminants with the record, which seems to be what you want, but I don't know of any compilers that do that. Also, if the discriminant has a default, and the record is not limited, then most compilers will store the maximum size, because the discriminants can change in that case. Some compilers instead use a level of indirection, which is still not zero size. I don't think this changed in Ada 2005. So for discriminated records, you're out of luck. - Bob