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,76dd26495a8f3b25 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-28 16:43:35 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Constant array declarations are not causing a compilation error when not fully initialized. Date: Tue, 28 Aug 2001 19:43:33 -0400 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <3B8C2CA5.9D957ED@avercom.net> References: <2d87db3f.0108230103.6326861e@posting.google.com> NNTP-Posting-Host: 192.168.24.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 999042214 7377 192.168.24.34 (28 Aug 2001 23:43:34 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 28 Aug 2001 23:43:34 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:12538 Date: 2001-08-28T23:43:34+00:00 List-Id: Mark Doherty wrote: > > Why does the Ada95 LRM not gaurantee a compilation error for the > following, albeit does produce a CONTRAINT_ERROR. This is similar to: "X : Positive := -1;" This is legal at compile-time, but will result in a constraint error at run-time. Most compilers are "friendly" enough to report cases where code will unevitably raise a Constraint_Error, but by the rules of the language, they are *not* allowed to reject such code as being illegal. The reason the rules don't require such rejection is that it is generally difficult to specify exactly how sophisticated such inevitable-run-time-error detection must be. In fact, Ada 95 goes further than Ada 83 in terms of specifying cases where inevitable-run-time-errors must be detected, but it clearly can't go all the way, as that would require the solution to the "halting" problem ;-). > > procedure Test is > > type Enum is (A, B, C); > > -- the following don't produce compilation errors (just warning on > different > -- versions of the compiler > Lookup_1 : constant array (Enum) of Integer := (A => 1); > Lookup_2 : constant array (Enum) of Integer := (A => 1, B => 2); > Lookup_3 : constant array (Enum) of Integer := (B => 1, C => 3); > Lookup_4 : constant array (Enum) of Integer := (10, 12); > > -- the following does produce compilation error (as expected) > Lookup_5 : constant array (Enum) of Integer := (A => 1,C => 2); > > begin > null; > end Test; > > p.s. Different versions of the Rational compiler (but not all) issue a > warning that ... CONSTRAINT_ERROR will be raised... -- -Tucker Taft stt@avercom.net http://www.avercom.net Chief Technology Officer, AverCom Corporation (A Titan Company) Bedford, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/~stt)