comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nick.roberts@acm.org>
Subject: Re: Zero length Objects
Date: Thu, 1 Jul 2004 16:26:23 +0100
Date: 2004-07-01T16:26:23+01:00	[thread overview]
Message-ID: <2kioovF2rj2qU1@uni-berlin.de> (raw)
In-Reply-To: cc15on$nsc5@cui1.lmms.lmco.com

"Xenos" <dont.spam.me@spamhate.com> 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





  reply	other threads:[~2004-07-01 15:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30  5:55 Zero length Objects Robert C. Leif
2004-06-30 20:32 ` Jacob Sparre Andersen
2004-06-30 21:01 ` Frank J. Lhota
2004-07-01  0:02   ` Nick Roberts
2004-07-01  1:28     ` Georg Bauhaus
2004-07-01 10:37       ` Björn Persson
2004-07-01 11:25     ` Larry Kilgallen
2004-07-01 14:11       ` Nick Roberts
2004-07-01 15:42         ` Larry Kilgallen
2004-07-01 14:06     ` Xenos
2004-07-01 15:26       ` Nick Roberts [this message]
2004-07-02  1:06         ` Jeffrey Carter
2004-07-01  0:47   ` Brian May
2004-07-01 13:32     ` Frank J. Lhota
2004-07-01 14:52       ` Nick Roberts
2004-07-01 15:03         ` Xenos
2004-07-01 15:57           ` Hyman Rosen
2004-07-01 16:05             ` Xenos
2004-07-02 15:02               ` Frank J. Lhota
2004-07-02 15:11                 ` Adrian Knoth
2004-07-02 15:43                   ` Frank J. Lhota
2004-07-02 19:01                     ` Vinzent 'Gadget' Hoefler
2004-07-02 19:07                       ` Adrian Knoth
2004-07-02 19:25                         ` Vinzent 'Gadget' Hoefler
2004-07-02 21:06                           ` Xenos
2004-07-02 21:56                             ` Vinzent 'Gadget' Hoefler
  -- strict thread matches above, loose matches on Subject: below --
2004-07-02  8:30 Christoph Karl Walter Grein
2004-07-06 11:59 ` Nick Roberts
2004-07-06 22:14   ` Randy Brukardt
2004-07-06 22:28     ` Nick Roberts
replies disabled

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