Re: Largest size array in Gnat 2005 for the PC?



On Oct 30, 2:40 pm, Georg Bauhaus <rm.tsoh+bauh...@xxxxxxxxxxxxxxxxxx>
wrote:
On Tue, 2007-10-30 at 13:24 -0700, Adam Beneschan wrote:
On Oct 30, 12:26 pm, Georg Bauhaus <rm.tsoh
Is there a bug in the following program or maybe I'm just dense?

EAX is a 32-bit register, right?

Yes, i686 Linux in this case. When I ask the compiler for
64bit code, then I see occurrences of $280375465082880,
which is 2**48 - 2**40.

So to assign into the first element of Fst, the offset from the
beginning of the array is 0; to assign into the last element, the
offset will be (2**48 - 2**40) which is 255 * 2**40, which is way too
big to fit into a 32-bit register, so apparently the compiler is
truncating to 0 before setting EAX.

Ah, yes. Could exceeding size have produced the -1 in
-1(%ebp,%eax), %eax
too? It is
-10002(%ebp,%eax), %eax
for the "normal size" array of 10_000 elements?

Your array is 10_001 elements, actually. I haven't studied code
produced by GNAT very much, but -1 just looks like the starting point
for where things are allocated (downward) from the current stack frame
pointer (EBP); exceeding size would have produced -1 in that if the
compiler truncates the array size and thinks the size is 0, then the
resulting offset would have been -1. I'll bet that if you declared an
array of one byte, you would have seen -2(%ebp,%eax); if it were two
bytes, -3(%ebp,%eax), and so on. I'm just speculating, though... I
haven't tried this myself.

-- Adam


.



Relevant Pages

  • Re: Idea for ECMA/C# Standard - compile time hash for performance
    ... I agree with you the chance of a compiler change is slim, ... and then delegating to the standard hash for fields accessed less frequently. ... or the array lookup which would require the ... > 64-bit architecture) for each enum value that doesn't map to anything. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Q: Checking the size of a non-allocated array?
    ... an actual argument is already invalid ... First note that you don't have an unallocated array in the subroutine. ... it is comparable to disassociated or undefined pointers. ... Obviously the compiler has ...
    (comp.lang.fortran)
  • Re: Windows array allocation problem
    ... array reference has to have a 64-bit index or array subscript triplet? ... to fit in one. ... That assumes, of course, that your compiler ... limits on just about anything. ...
    (comp.lang.fortran)
  • Re: Error handling library
    ... which lets the compiler catch out-of-range usage. ... and assuming that a higher int means "more dangerous error" ... with a comment warning that one is used as an index into the array ... languages while running (an array of languages, ...
    (comp.lang.c)
  • Bounds checked arrays
    ... As everybody knows, the C language lacks ... When the state of this toggle is ON, the compiler ... Important is to know that the array updates ... We have just to allow him/her to specify what to do ...
    (comp.lang.c)