From: prichtmyer@yahoo.com (Peter Richtmyer)
Subject: Null Record is not always Null
Date: 10 Oct 2002 06:12:01 -0700
Date: 2002-10-10T13:12:01+00:00 [thread overview]
Message-ID: <1b585154.0210100512.54af8543@posting.google.com> (raw)
This is a little on the light side, but is also
frustrating to see in "portable Ada". Perhaps others
with different compilers will find even different
results.
-----------------------------------------------------
with Text_Io;
procedure nil is
type nul is null record;
for nul'size use 0;
nil : nul;
type aray is array (1 .. 1000) of nul;
-- pragma pack (aray); -- line 7
-- for aray'size use 0; -- line 8
ary : aray;
type dbl is array (1 .. 1000) of aray;
-- pragma pack (dbl); -- line 11
-- for dbl'size use 0; -- line 12
dub : dbl;
begin
text_io.put_line ("Nil size = " & integer'image(nil'size));
text_io.put_line ("Ary size = " & integer'image(ary'size));
text_io.put_line ("Dub size = " & integer'image(dub'size));
--------------------------------------------
-- output on Gnat 3.14p (win2000):
-- Nil size = 8
-- Ary size = 8
-- Dub size = 8
--------------------------------------------
-- Rational Apex Ada 95 v. 4.0.0b (Solaris)
-- (would not compile until I commented out lines 8 & 12)
-- 06:39:44 AM >>> Line 8: for Aray'Size use 0;
-- 06:39:44 AM *** Specified size 0 is too small for array (1 .. 1000) of Nul
-- 06:39:44 AM ++* nil.2.ada has failed to install in ...
-- 06:39:50 AM +++ 1 unit was parsed
-- 06:39:50 AM ++* 1 unit could not be installed
--
-- Rational output with lines 8 & 12 commented out:
-- Nil size = 0
-- Ary size = 1000
-- Dub size = 1000000
--------------------------------------------
-- Aonix ObjectAda 7.1.105 Professional Version (win2000)
-- (Would not compile. Window said:)
-- Program Error
-- ADACOMP.exe has generated errors and will be closed by
-- Windows. You will need to restart the program.
-- An error log is being created.
-- It did not close. I could not find an error log.
-- In order to even start compiling, I had to comment lines 7,8,11,12
-- Then output was:
-- Nil size = 0
-- Ary size = 0
-- Dub size = 0
-- which is what I wanted!
---------------------------------------------
end nil;
-----
Don't know if there is a "right" result, or is this one of
those gray areas. Anybody?
Peter
next reply other threads:[~2002-10-10 13:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 13:12 Peter Richtmyer [this message]
2002-10-10 14:16 ` Null Record is not always Null Colin Paul Gloster
2002-10-10 15:44 ` Robert A Duff
2002-10-10 16:44 ` Colin Paul Gloster
2002-10-10 17:28 ` Robert A Duff
2002-10-22 19:00 ` Randy Brukardt
2002-10-10 15:38 ` Robert A Duff
2002-10-11 1:39 ` Peter Richtmyer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox