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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7bdbcdc23dd9313d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!o14g2000prn.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: Large arrays passed to arithmetic operators overflows GNAT stack Date: Sat, 4 Dec 2010 17:22:04 -0800 (PST) Organization: http://groups.google.com Message-ID: <9c9dda40-e104-447a-8259-b7ab7d1f36f7@o14g2000prn.googlegroups.com> References: NNTP-Posting-Host: 75.172.183.76 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1291512124 29845 127.0.0.1 (5 Dec 2010 01:22:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 5 Dec 2010 01:22:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o14g2000prn.googlegroups.com; posting-host=75.172.183.76; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/531.21.8+(KHTML, like Gecko, Safari/528.16) (null),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:16784 Date: 2010-12-04T17:22:04-08:00 List-Id: On Dec 4, 7:17 am, "Peter C. Chapin" wrote: > On 2010-12-04 01:32, Jerry wrote: > > > with > > Ada.Numerics.Long_Real_Arrays; > > use > > Ada.Numerics.Long_Real_Arrays; > > procedure array_test is > > type Real_Vector_Access is access Real_Vector; > > N : Integer := 1_048_130; > > t_Ptr : Real_Vector_Access := new Real_Vector(0 .. N); > > t : Real_Vector renames t_Ptr.all; > > I don't think you need this renaming. If you do t_Ptr'Range or t_Ptr(i) > the compiler will forward those operations directly to the object. > ... > Peter That is true but the renaming is still convenient for other reasons. For example, the lines t : Real_Vector_Access := new Real_Vector(0 .. N); t_Diff : Real_Vector_Access := new Real_Vector(0 .. N - 1); ... [Line 14] t_Diff := t(1 .. N); causes the complaints expected type "Real_Vector_Access" defined at line 14 found type "Ada.Numerics.Generic_Real_Arrays.Real_Vector" from instance at a-nlrear.ads:18 And passing t to a vector cosine (e.g.) function that expects to see a Real_Vector will also fail. Of course, with two like pointers t and x, assignment t := x assigns the pointers, not the array contents, and with three like pointers t, x, y, t := x - y fails to find an applicable operator function. This clever renaming trick was mentioned by Brian Drummond in this thread: http://groups.google.com/group/comp.lang.ada/browse_thread/thread/ae395e5c11de7bc9/bda8d61bd3a66ee9?hl=en&q=Jerry+stack&lnk=nl& Jerry