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,18352ac39491e701 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.228.227 with SMTP id sl3mr17435585pbc.5.1340733777576; Tue, 26 Jun 2012 11:02:57 -0700 (PDT) Path: l9ni22815pbj.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Why this error, value not in range of subtype of "Standard.Integer"? Date: Tue, 26 Jun 2012 10:20:39 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1340733777 5464 127.0.0.1 (26 Jun 2012 18:02:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 26 Jun 2012 18:02:57 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-06-26T10:20:39-07:00 List-Id: On Tuesday, June 26, 2012 8:49:18 AM UTC-7, Nasser M. Abbasi wrote: > experts; > > If I write this, I get an error as show: (notice the B > matrix declaration, that is where the problem is) > > -------------- this does not work ------ > with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays; > > procedure foo2 is > A : constant Real_Matrix := > (( 1.0, 2.0, 3.0), > ( 4.0, 5.0, 6.0), > ( 7.0, 8.0, 9.0)); > B : Real_Matrix(1 .. 3,1 .. 3); -- this is the problem > begin > > FOR I in A'range(1) LOOP > FOR J in A'range(2) LOOP > B(I,J) := 1.0; > END LOOP; > END LOOP; > > end foo2; > ------------------------------- > > >gnatmake foo2.adb > gcc-4.6 -c foo2.adb > foo2.adb:13:17: warning: value not in range of subtype of "Standard.Integer" defined at line 8 > foo2.adb:13:17: warning: "Constraint_Error" will be raised at run time > foo2.adb:13:19: warning: value not in range of subtype of "Standard.Integer" defined at line 8 > foo2.adb:13:19: warning: "Constraint_Error" will be raised at run time > gnatbind -x foo2.ali > gnatlink foo2.ali > > But if I change the declaration of B from > B : Real_Matrix(1 .. 3,1 .. 3); > to > B : Real_Matrix(A'RANGE(1), A'RANGE(2)); > > then Ada is happy now. > > Isn't A'RANGE(1) the same as 1 .. 3 and A'RANGE(2) the same as 1 .. 3? > or is this one of those typing issues? A'Range(1) is the same as A'First(1) .. A'Last(1), which is in this case -2147483648 .. -2147483646, not 1 .. 3. I've said more about this in my response on another thread. -- Adam