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,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b637950a34ec2d6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-07 05:48:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!freenix!enst!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: Discriminated record question Date: Tue, 7 May 2002 14:45:34 +0200 (MET DST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1020775682 66007 137.194.161.2 (7 May 2002 12:48:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 7 May 2002 12:48:02 +0000 (UTC) Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: S4VjuUmKiuXrkdEjBtIOhQ== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk X-Reply-To: "Grein, Christoph" List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:23638 Date: 2002-05-07T14:45:34+02:00 > From: Mark.Doherty@uk.thalesgroup.com (Mark Doherty) > > Why does the following raise a constraint error on the declaration of > 'B'. > > procedure Test is > type A_Type (Text_Size : Natural := 0) is > record > Text : String (1 .. 0); > end record; > A : A_Type; Text component is always empty here, whichever Text_Size you use, so all objects have the same (small) size. > > type B_Type (Text_Size : Natural := 0) is > record > Text : String (1 .. Text_Size); > end record; > > B : B_Type; I presume, Storage_Error is raised, not Constraint_Error as you claim. Here Text component depends on Text_Size. You define an unconstrained object, so the discriminant can vary, therefore the compiler has to allocate the maximum size, which is Natural'Last - quite big I'd say. (A different model could be implemented by implicitly allocating on the heap as much storage as is currently needed. But this model is rarely used - is it currently used at all by some compiler?) So the difference is not so subtle...