comp.lang.ada
 help / color / mirror / Atom feed
* Problem taking 'Size of large array (gnat)
@ 2000-09-13  0:00 Dr Adrian Wrigley
  2000-09-13  0:00 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: Dr Adrian Wrigley @ 2000-09-13  0:00 UTC (permalink / raw)


I have encountered a problem running code for handling large records and arrays.

Although the ARM says the 'Size attribute is a universal integer, I
cannot use the attribute when the expected value would exceed 31 bits.
This becomes a problem when the size of the object exceeds 256MB.
I was trying to memory map (mmap) a file containing a large record.

I am using gnat 3.12p on x86/Linux

Questions:

1)  Does this problem exist on the other popular Ada implementations on x86?
2)  How can I compute the size in bytes of objects > 256MB?

Example code is below...
--------------
with Text_IO; use Text_IO;

procedure ShowSize is

   type Big is array (0 .. 70_000_000) of Float;
   type Long is range 0 .. 2**63 - 1;
   X : Long;

begin

   X := Big'Size; -- Constraint error here!

   Text_IO.Put_Line ("X got " & Long'Image (X));

end ShowSize;
---------------
--
Dr Adrian Wrigley, (currently in Vancouver, BC)




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

* Re: Problem taking 'Size of large array (gnat)
  2000-09-13  0:00 Problem taking 'Size of large array (gnat) Dr Adrian Wrigley
@ 2000-09-13  0:00 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 2000-09-13  0:00 UTC (permalink / raw)


Dr Adrian Wrigley <amtw@linuxchip.demon.co.uk> writes:

> with Text_IO; use Text_IO;
> 
> procedure ShowSize is
> 
>    type Big is array (0 .. 70_000_000) of Float;
>    type Long is range 0 .. 2**63 - 1;
>    X : Long;
> 
> begin
> 
>    X := Big'Size; -- Constraint error here!

This looks like a compiler bug to me.  Big'Size is not a static
expression, but RM-3.5.4(14) defines the base range to be System.Min_Int
.. System.Max_Int.  Calculations can't overflow unless they go outside
the base range of the type.  The fact that your compiler allowed the
declaration of Long proves that System.Max_Int is at least 2**63-1.
In fact, I believe that System.Max_Int is exactly 2**63-1 in all
versions of GNAT.

- Bob




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

end of thread, other threads:[~2000-09-13  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-13  0:00 Problem taking 'Size of large array (gnat) Dr Adrian Wrigley
2000-09-13  0:00 ` Robert A Duff

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