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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d9241cc896c5fa1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-01 08:55:16 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!news2.euro.net!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: To_Unbounded_String and PROGRAM_ERROR X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C5AC489.70CCB3F1@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Fri, 1 Feb 2002 16:38:33 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:19492 Date: 2002-02-01T16:38:33+00:00 List-Id: Michal Nowikowski wrote: > > --- > Path : array(1..1500) of Unbounded_String; > ... > for I in 1..1500 loop > Path(I) := To_Unbounded_String(Get_Current_Dir & Some_String); > end loop; > --- > > and get sth like that > raised PROGRAM_ERROR : a-strunb.ads:368 > > This occure after few iterations - it depends of length of converted > string. It looks for me that the limmit of memory is exceeded. > Have You any idea how to cope with it? What platform and compiler? This looks like a GNAT message; in GNAT, stack checking is off by default. Read the documentation for information about turning it on. That might give you more information. Part of the problem may be that every iteration performs the concatenation (may create a temporary), conversion to Unbounded_String (may create a temporary), and assignment (which probably performs finalization). Since the string appears to be constant, something like Path_Value : constant Unbounded_String := To_Unbounded_String (...); ... Path := (others => Path_Value); might be better. Another possibility is type Path_List is array (1 .. 1_500) of Unbounded_String; Path : Path_List := (others => Path_Value); which should eliminate many temporaries and the finalization, since this is an initialization, not an assignment, or Initial_Path : constant Path_List := (others => Path_Value); Path : Path_List := Initial_Path; though this might double the memory usage. Note that it is generally considered better to say for I in Path'range than to repeat the magic numbers 1 and 1_500. -- Jeffrey Carter