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 autolearn=ham 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-08 19:56:56 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dewar@gnat.com (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Discriminated record question Date: 8 May 2002 19:56:55 -0700 Organization: http://groups.google.com/ Message-ID: <5ee5b646.0205081856.63e2639e@posting.google.com> References: <2d87db3f.0205080210.34726bf3@posting.google.com> NNTP-Posting-Host: 205.232.38.14 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1020913016 1992 127.0.0.1 (9 May 2002 02:56:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 9 May 2002 02:56:56 GMT Xref: archiver1.google.com comp.lang.ada:23750 Date: 2002-05-09T02:56:56+00:00 List-Id: Mark.Doherty@uk.thalesgroup.com (Mark Doherty) wrote in message news:<2d87db3f.0205080210.34726bf3@posting.google.com>... > Does the compiler have the freedom to raise it as a > Constraint_Error? Highly dubious if you ask me. Report it as a bug. Note that GNAT is so kind as to give you a warning if you declare a type like this: 1. package q is 2. type x (a : natural := 0) is record 3. s : string (1 .. a); | >>> warning: creation of object of this type may raise Storage_Error 4. end record; 5. 6. ss : x; | >>> warning: Storage_Error will be raised at at run-time 7. end; And sure enough, if you run this program, Storage_Error will be raised. I really think raising Constraint_Error is very dubious here. What is likely going on is that the compiler is getting an overflow trying to compute the maximum size of the object. As I said earlier, I would report it as a bug. The warnings in GNAT are quite useful (checkout the -gnatw flag for turning them on, at the very least -gnatwu should be used pretty much all the time, the only reason it is not the default is that making it the default would require the modification of literally hundreds of tests in our test suite :-) Robert Dewar Ada Core Technologies