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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.52.66.140 with SMTP id f12mr4839387vdt.5.1425480429363; Wed, 04 Mar 2015 06:47:09 -0800 (PST) X-Received: by 10.140.102.82 with SMTP id v76mr76164qge.25.1425480429171; Wed, 04 Mar 2015 06:47:09 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k15no142212qaq.1!news-out.google.com!qk8ni49443igc.0!nntp.google.com!k15no142211qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 4 Mar 2015 06:47:08 -0800 (PST) In-Reply-To: <851b7d3c-4ac3-4fba-852d-c2975050da74@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a00:d90:11f:2:e444:a829:15c1:d102; posting-account=0iOirAoAAADtoPTYSfPIpnLBQ4gI6dZq NNTP-Posting-Host: 2a00:d90:11f:2:e444:a829:15c1:d102 References: <851b7d3c-4ac3-4fba-852d-c2975050da74@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6e064a46-938f-4861-b56a-56c9e75c256d@googlegroups.com> Subject: Re: SPARK internal error? From: joakim.strandberg@cxense.com Injection-Date: Wed, 04 Mar 2015 14:47:09 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 4624 X-Received-Body-CRC: 80871718 Xref: news.eternal-september.org comp.lang.ada:25102 Date: 2015-03-04T06:47:08-08:00 List-Id: On Tuesday, March 3, 2015 at 10:54:08 AM UTC+1, Maciej Sobczak wrote: > As a continuation of my previous post, here is the complete package with the array sorting exercise (not sure if it's correct): > > Package spec: > > pragma SPARK_Mode; > > package My_Package is > > type Index is range 1 .. 10; > type My_Array is array (Index range <>) of Integer; > > procedure Find_Min (A : in My_Array; I : out Index) > with Pre => A'First <= A'Last, > Post => > (I in A'Range and > (for all J in A'Range => > A (I) <= A (J))); > > procedure Min_To_Left (A : in out My_Array) > with Pre => A'First <= A'Last, > Post => > (for all I in A'Range => A (A'First) <= A (I)); > > procedure Sort (A : in out My_Array) > with Pre => A'First <= A'Last, > Post => > (for all I in A'Range => > (for all J in I .. A'Last => > A (I) <= A (J))); > > end My_Package; > > > Package body: > > pragma SPARK_Mode; > > package body My_Package is > > procedure Find_Min (A : in My_Array; I : out Index) is > Last_Min : Integer; > begin > I := A'First; > Last_Min := A (A'First); > > for J in A'First + 1 .. A'Last loop > > if A (J) < Last_Min then > I := J; > Last_Min := A (J); > end if; > > pragma Loop_Invariant > (for all K in A'First .. J => > I in A'First .. J and Last_Min = A (I) and Last_Min <= A (K)); > end loop; > end Find_Min; > > procedure Min_To_Left (A : in out My_Array) is > I : Index; > Tmp : Integer; > begin > Find_Min (A, I); > > Tmp := A (A'First); > A (A'First) := A (I); > A (I) := Tmp; > end Min_To_Left; > > procedure Sort (A : in out My_Array) is > begin > for I in A'Range loop > Min_To_Left (A (I .. A'Last)); > > pragma Loop_Invariant > (for all J in I .. A'Last => > A (I) <= A (J)); > end loop; > end Sort; > > end My_Package; > > GNATprove says: > > C:\maciej\temp\spark>gnatprove -Ptest -q > Internal error: > File "C:\maciej\temp\spark\gnatprove\my_package\..\my_package.mlw", line 2094, characters 208-235: > This term has type tindexB, but is expected to have type int. > Aborting. > gprbuild: *** compilation phase failed > gnatprove: error during generation and proof of VCs, aborting. > > > The my_package.mlw file has explicit content and is unappropriate for Usenet publication. ;-) > > Can you reproduce it? Is it a bug in the toolset? > How can I work around it? > > -- > Maciej Sobczak * http://www.inspirel.com/ Dear Maciej, Your probably already know this but I have found that the SPARK mailing list is a great place to ask SPARK questions: http://lists.forge.open-do.org/pipermail/spark2014-discuss/ It is moderated but all questions I've posted so far have been accepted and answered shockingly fast by Yannick Moy (although there are other active users there too). Best regards, Joakim Strandberg