From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b3ebf057333800c X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!i38g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Largest size array in Gnat 2005 for the PC? Date: Tue, 30 Oct 2007 14:48:45 -0700 Organization: http://groups.google.com Message-ID: <1193780925.196642.17450@i38g2000prf.googlegroups.com> References: <13idb3jbm28kfbe@corp.supernews.com> <1193737660.539205.271270@57g2000hsv.googlegroups.com> <1193772402.13888.130.camel@kartoffel> <1193775877.289991.52560@y27g2000pre.googlegroups.com> <1193780421.3259.46.camel@kartoffel> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1193780928 14285 127.0.0.1 (30 Oct 2007 21:48:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 30 Oct 2007 21:48:48 +0000 (UTC) In-Reply-To: <1193780421.3259.46.camel@kartoffel> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i38g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2658 Date: 2007-10-30T14:48:45-07:00 List-Id: On Oct 30, 2:40 pm, Georg Bauhaus wrote: > On Tue, 2007-10-30 at 13:24 -0700, Adam Beneschan wrote: > > On Oct 30, 12:26 pm, Georg Bauhaus > > 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