comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: for Object_Size use 0
Date: 13 Apr 2005 11:51:46 -0400
Date: 2005-04-13T11:51:46-04:00	[thread overview]
Message-ID: <wcczmw2isj1.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: mailman.18.1113357147.24457.comp.lang.ada@ada-france.org

"Robert C. Leif" <rleif@rleif.com> 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



  parent reply	other threads:[~2005-04-13 15:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-13  1:52 for Object_Size use 0 Robert C. Leif
2005-04-13  7:58 ` Martin Dowie
2005-04-13 15:51 ` Robert A Duff [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-04-13 12:02 Robert C. Leif
2005-04-14  5:20 Christoph Grein
2005-04-14 14:48 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox