comp.lang.ada
 help / color / mirror / Atom feed
* Null Record is not always Null
@ 2002-10-10 13:12 Peter Richtmyer
  2002-10-10 14:16 ` Colin Paul Gloster
  2002-10-10 15:38 ` Robert A Duff
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Richtmyer @ 2002-10-10 13:12 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-10-22 19:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10 13:12 Null Record is not always Null Peter Richtmyer
2002-10-10 14:16 ` 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

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