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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Dynamic_Predicate failure -> Assertion_Error? Date: Tue, 13 May 2014 13:22:27 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <87tx8tncss.fsf@adaheads.sparre-andersen.dk> NNTP-Posting-Host: 3408ds2-vbr.0.fullrate.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1399980147 32750 90.184.74.58 (13 May 2014 11:22:27 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 13 May 2014 11:22:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:WDGqu2VFwPIpsK62YHy6mRXeVlM= Xref: news.eternal-september.org comp.lang.ada:19798 Date: 2014-05-13T13:22:27+02:00 List-Id: I am experimenting a bit with GNAT-GPL-2013 and some of the new features in Ada 2012. % cat primes.ads package Primes is subtype Prime is Integer range 2 .. Integer'Last with Dynamic_Predicate => (for all N in 2 .. Prime - 1 => Prime mod N /= 0); end Primes; % cat test_primes.adb with Ada.Assertions, Ada.Text_IO; with Primes; procedure Test_Primes is use Primes; P : Prime; begin for I in 1 .. 25 loop begin P := I; Ada.Text_IO.Put_Line (Prime'Image (P) & " is a prime."); exception when Constraint_Error => Ada.Text_IO.Put_Line (Integer'Image (I) & " is not a prime (constraint)."); when Ada.Assertions.Assertion_Error => Ada.Text_IO.Put_Line (Integer'Image (I) & " is not a prime (predicate)."); end; end loop; end Test_Primes; % gnatmake -gnat12 -gnata -gnato -fstack-check test_primes gcc -c -gnat12 -gnata -gnato -fstack-check test_primes.adb gcc -c -gnat12 -gnata -gnato -fstack-check primes.ads gnatbind -x test_primes.ali gnatlink test_primes.ali -fstack-check % ./test_primes 1 is not a prime (constraint). 2 is a prime. 3 is a prime. 4 is not a prime (constraint). [...] As I read 3.2.4(31/3) the raised exception for 4 should be Assertion_Error and not Constraint_Error. Is this correct? If I am correct, is there any likelihood that I could get a test for this into ACATS (assuming that I can figure out how to formulate it properly)? Greetings, Jacob -- "I don't want to gain immortality in my works. I want to gain it by not dying."