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!news1.google.com!news.glorb.com!news.doubleslash.org!open-news-network.org!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Largest size array in Gnat 2005 for the PC? From: Georg Bauhaus In-Reply-To: <1193775877.289991.52560@y27g2000pre.googlegroups.com> References: <13idb3jbm28kfbe@corp.supernews.com> <1193737660.539205.271270@57g2000hsv.googlegroups.com> <1193772402.13888.130.camel@kartoffel> <1193775877.289991.52560@y27g2000pre.googlegroups.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1193780421.3259.46.camel@kartoffel> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Date: Tue, 30 Oct 2007 22:40:21 +0100 Organization: Arcor NNTP-Posting-Date: 30 Oct 2007 22:39:45 CET NNTP-Posting-Host: 6a1b4c3c.newsspool2.arcor-online.net X-Trace: DXC==dELlLZkE`F@Y=h<_c3PkHA9EHlD;3YcB4Fo<]lROoRA4nDHegD_]RE_`Y6g1[KJ^CN[W 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? > But you're declaring an array object X of size 255*(2**40), which > can't be handled on a machine with a 32-bit address space; so I'm > confused about why you'd expect the program to work, I didn't expect this program to work, really, other than through advanced OS magic or due to my limited knowledge of Ada details. Another compiler, though, targeting a 64bit platform, produces the exact same output. So I hesitated to say that they both are producing incorrect code for this case. But: > Anyway, however, this looks like a > compiler bug---if it is unable to generate correct code because of the > array size, it should reject the program. Thanks for explaining this. Oh, there is more evidence as I write this. I don't have a recent GCC right now to see whether this is still a bug; I'll try to build one, but if one of you has a recent GCC and can reproduce the behavior, you'd be saving me a few minutes this weekend :-) -Os was the crucial addition to the command line. kartoffel% gnatmake -W -gnatp -S -s -march=x86-64 -m64 -Os stk.adb gcc-4.1 -c -W -gnatp -S -march=x86-64 -m64 -Os stk.adb +===========================GNAT BUG DETECTED==============================+ | 4.1.2 (Ubuntu 4.1.2-0ubuntu4) (i486-pc-linux-gnu) GCC error: | | in pro_epilogue_adjust_stack, at config/i386/i386.c:5094 | | Error detected at stk.adb:41:5 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact gcc-4.1 or gnatmake command that you entered. | | Also include sources listed below in gnatchop format | | (concatenated together with no headers between files). | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. stk.adb raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:380 gnatmake: "stk.adb" compilation error