From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 9 Nov 91 03:20:55 GMT From: eachus@mitre-bedford.arpa (Robert I. Eachus) Subject: Re: Is this legal ? Message-ID: List-Id: In article <1991Nov08.205832.26958@convex.com> pelakh@convex.com (Boris Pelakh) writes: The following procedure produces a warning at compile time saying that the declaration of NULL_LINE is exceeding the storage limit of the implementation. At runtime, I get a storage error. It looks like the unconstrined declare is causing an attempt to allocate a STRING(1..MAX_INT), even though I would expect it to only declare a STRING(1..10). The RM does not explain this particular case. Any ideas ? Why would you expect it to allocate space for only 10 characters? The object NULL_LINE can be used to store a STRING value of any size, since the discriminant has a default and is of type INTEGER. There are two standard implementations of such records, the `hidden pointer' version which stores the actual values on the heap, and an allocate the maximum strategy. (Some compilers implement both, with a size at which they cut over.) If you want to store reasonable length lines in a portable way, try: procedure NOT_BROKE is subtype LINE_LENGTH is INTEGER range 0..1024; type VAR_LINE(LENGTH : LINE_LENGTH := 10) is record IMAGE : STRING(1..LENGTH); end record; NULL_LINE : VAR_LINE; begin null; end BROKE; -- Robert I. Eachus with STANDARD_DISCLAIMER; use STANDARD_DISCLAIMER; function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...