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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,133de21eb82605b X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: How do functions return unbounded arrays? Date: 1998/06/17 Message-ID: #1/1 X-Deja-AN: 363444044 References: <358444BA.757121D8@cl.cam.ac.uk> <1998061518584100.OAA28557@ladder01.news.aol.com> Organization: Network Intensive Newsgroups: comp.lang.ada Date: 1998-06-17T00:00:00+00:00 List-Id: johnherro@aol.com (John Herro) writes: > > Are there Ada programs that cause a heap > > overflow just by calling "&" in a long loop? > > That question I can answer definitely. The following program raises > Storage_Error on my machine when compiled with Open Ada (an Ada 83 > compiler). [program example snipped] This is hardly a definate answer. All it proves is that in one Ada 83 implementation, storage error gets raised. We could probably make the storage error go away by declaring the string in a nested block: procedure Test is begin for L in Long_Integer range 10_000_000 .. 99_999_998 loop declare S : constant String := Long_Integer'Image(L) & Long_Integer'Image(L + 1); begin null; end; end loop; end Test; I think the memory will get cleaned up when the frame terminates (that is, every pass through the loop), and therefore storage_error won't happen.