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-Thread: 103376,8e97b70a5f7d5495 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Brain bug or GNAT bug? References: <87irdlx1ol.fsf@ludovic-brenta.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1172725655 12.201.97.213 (Thu, 01 Mar 2007 05:07:35 GMT) NNTP-Posting-Date: Thu, 01 Mar 2007 05:07:35 GMT Organization: AT&T ASP.att.net Date: Thu, 01 Mar 2007 05:07:35 GMT Xref: g2news2.google.com comp.lang.ada:9612 Date: 2007-03-01T05:07:35+00:00 List-Id: (see below) wrote: > >>> generic >>> type modular is mod <>; >>> package try is >>> >>> type DT1 (the_size : modular) is limited private; >>> >>> -- subtype bounded is modular; >>> subtype bounded is modular range 1..9; > But if the declaration of bounded compiles, > the range of bounded must be a subset of the range of modular, > so DT2.the_size must be in the range of modular. > The rule at ARM 3.7(15) seems overly restrictive. Consider: with Ada.Command_Line; procedure Modular_Subtype is type Modular is mod 2 ** 32; Low : constant Modular := Modular'Value (Ada.Command_Line.Argument (1) ); High : constant Modular := Modular'Value (Ada.Command_Line.Argument (2) ); subtype Mod_Sub is Modular range Low .. High; generic -- Modular_Parameter type Modular is mod <>; package Modular_Parameter is subtype Bounded is Modular range 1 .. 9; -- Line 16 end Modular_Parameter; package Instantiation is new Modular_Parameter (Modular => Mod_Sub); begin -- Modular_Subtype null; end Modular_Subtype; This compiles (with a warning that Instantiation is not referenced). Since the instantiation cannot be checked during compilation, it is checked at run time. Here's a sample run: D:\Code>modular_subtype 10 24 raised CONSTRAINT_ERROR : modular_subtype.adb:16 range check failed Here's another: D:\Code>modular_subtype 0 10 D:\Code> -- Jeff Carter "I unclog my nose towards you." Monty Python & the Holy Grail 11