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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e5a3abec221df39 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!m3g2000hsc.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Possible compiler bug with this simple program Date: Thu, 28 Aug 2008 00:56:36 -0700 (PDT) Organization: http://groups.google.com Message-ID: <891f5fdc-195e-47a3-a269-04d1d9234b97@m3g2000hsc.googlegroups.com> References: <1edc3682-855f-405b-8348-72b423377b1a@i20g2000prf.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1219910196 29340 127.0.0.1 (28 Aug 2008 07:56:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 28 Aug 2008 07:56:36 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m3g2000hsc.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3) Gecko/20040924,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7534 Date: 2008-08-28T00:56:36-07:00 List-Id: Jerry wrote: > The following is a program which emulates the structure of a binding > to a bunch of C code (but there is no C code included here--it is all > Ada). This structure exhibits a behavior which I think might be a > compiler error but could be the result of incorrect declarations when > running on certain machines. > > Specifically, the program compiles (with two warnings which are > expected and OK) and runs correctly on my machine, OS X 10.4.11 > running GNAT 4.3.0 (32-bit PowerPC G4). However, on someone else's > box, a 64-bit Intel Duo running Debian lenny and GNAT 4.3.1-2, the > program compiles but bombs at runtime with > > raised STORAGE_ERROR : stack overflow (or erroneous memory access) > > reported. I cannot test your program now but it seems to me that perhaps you should specify the alignment of the arrays and Long_Floats. Also, it might be a good idea to double-check that on the Intel Core 2, the long floats are really 64 bits and not 80 bits wide. It could be that the compiler got that wrong but I doubt it. Also, have you tried to compare the assembly language emitted by the compiler with and without pragma Convention? (try gnatmake -c -cargs - S) [...] > As a second problem, in the program above there is a loop line that > looks like this: > > for i in 0 .. n - 1 loop > > One would normally write this as > > for i in x'range loop > > but when this runs on the OS X box, it segfaults after printing about > 187 lines of bogus floats. I don't know what happens on the Debian > box. However, if the -- *** lines are commented out, it runs OK on OS > X. This is to be expected. With convention C, there is no array anymore; instead the procedure receives a pointer to the first element of the array, so it doesn't have any information about the range. That's why it is necessary to pass the length of the array separately. HTH -- Ludovic Brenta.