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: a07f3367d7,c550113251b19a6 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!feeder.news-service.com!cyclone01.ams2.highwinds-media.com!news.highwinds-media.com!npeersf02.ams.highwinds-media.com!newsfe30.ams2.POSTED!40385e62!not-for-mail Message-ID: <4A1FCD6C.3070000@bredband.net> From: Per Sandberg User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Error: "could not understand bounds information on packed array" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@WWWSpace.NET NNTP-Posting-Date: Fri, 29 May 2009 12:52:05 UTC Date: Fri, 29 May 2009 13:56:28 +0200 Xref: g2news2.google.com comp.lang.ada:6100 Date: 2009-05-29T13:56:28+02:00 List-Id: Well. As you say stacks will be exhausted sooner or later if you are writing indefinite recursive algorithms. And of course its possible to set the upper stack limit. The simplest way is to add "pragma Linker_Options" in your main. As i did in your sample. /Per ---------------- with Ada.Text_IO; use Ada.Text_IO; procedure Testsuite is pragma Linker_Options ("-Wl,--stack=0x4000000"); procedure Recursive_Call (Index : in out Integer) is begin Index := Index + 1; Ada.Text_IO.Put_Line (Integer'Image (Index)); Recursive_Call (Index); end Recursive_Call; begin declare I : Integer := 0; begin Recursive_Call (I); Ada.Text_IO.Put_Line (Integer'Image (I)); end; end Testsuite; /Per Dennis Hoppe wrote: > Now, I am sure it is "just" a recursion issue. The following test > terminates after just 87.354 iterations: > > > with Ada.Text_IO; use Ada.Text_IO; > > procedure Testsuite is > > procedure Recursive_Call (Index : in out Integer) is > begin > Index := Index + 1; > Ada.Text_IO.Put_Line (Integer'Image (Index)); > Recursive_Call (Index); > end Recursive_Call; > > begin > declare > I : Integer := 0; > begin > Recursive_Call (I); > Ada.Text_IO.Put_Line (Integer'Image (I)); > end; > end Testsuite; > > > Output: > > [..] > 87354 > > raised STORAGE_ERROR : stack overflow > > Well, I didn't provide a suitable base case for termination. I just > wanted do find out the upper bound of recursive calling. > > For me, 87.354 seems to be a very low upper bound of recursion. An > adapted version in Java runs 519.045 recursion steps before a > StackOverflowError occurs on the same machine. > > It is clear, that I cannot indefinitely call a procedure recursively. > Unfortunately, I cannot predict in advance, how many recursion steps > my program have to proceed. How can I avoid the stack overflow in > recursion? Can I influence the upper bound of recursive calls, i.e the > size of the run-time stack? > > Thank you, > Dennis > >