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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.109.59.165.174.mobile.3.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: GNAT bug with assertions Date: Fri, 10 Aug 2018 17:16:14 +0200 Organization: JSA Research & Innovation Message-ID: <87y3dejlq9.fsf@adaheads.home> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: franka.jacob-sparre.dk; posting-host="109.59.165.174.mobile.3.dk:109.59.165.174"; logging-data="27261"; mail-complaints-to="news@jacob-sparre.dk" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:CXlCuWflSqfX0V8d9CK2+ILvPso= Xref: reader02.eternal-september.org comp.lang.ada:54127 Date: 2018-08-10T17:16:14+02:00 List-Id: AdaMagica wrote: > I would have expected that predicates are also checked on return > values as they are checked on parameters. In the following test, no > exception is raised on call of funcction Wrong although it returns a > value not fulfilling the predicate. > > Is this a GNAT bug or my wrong expectation? It seems that your expectations are slightly off. Contracts are only checked if the assertion policy is set to "Check". You can do that, either by configuring your compiler to have the assertion policy set to "Check", or by explicitly inserting: pragma Assertion_Policy (Check); at the beginning of the units, which should have this assertion policy. If I remember correctly, setting the assertion policy of a package specification to "Check" means that the contracts of the subprograms specified in the package are checked, even if they are called from a unit with assertion policy "Ignore". Greetings, Jacob -- Computers are not intelligent. They only think they are.