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,b7566e485e23e171 X-Google-Attributes: gid103376,public From: Andre Spiegel Subject: Re: Changing discriminants at run-time: erroneous execution? Date: 1996/08/08 Message-ID: #1/1 X-Deja-AN: 172927805 sender: spiegel@berlin.berlin.informatik.uni-stuttgart.de references: organization: University of Stuttgart, Germany newsgroups: comp.lang.ada Date: 1996-08-08T00:00:00+00:00 List-Id: Thanks to all who replied to my question, both here and in private e-mail. I think I understand the issue now. In summary, it *is* possible to "resize" arrays via discriminants, but compilers normally achieve this by allocating an object of the maximum possible size. So using an array index of type Natural almost certainly fails, leading to a stack overflow. I should use a subtype, maybe of range 1..500 or some such. We got bitten by a yet-unimplemented feature in GNAT; so that the problem was not reported by the run-time system -- which should normally happen. Anyway, I normally allocate dynamic arrays on the heap, or declare them only after the bounds are known, so I hadn't come across this problem yet. Also, for dynamic _strings_, the standard libraries Ada.Strings.Bounded/Unbounded are the way to go, of course. The issue was raised by programs that somebody else in our group had written; I looked at these programs, and I really had no idea why they failed so mysteriously. Thanks again to everyone, Andre Spiegel University of Stuttgart, Germany