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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: GNAT bug with assertions Date: Mon, 13 Aug 2018 16:54:26 +0100 Organization: A noiseless patient Spider Message-ID: References: <87y3dejlq9.fsf@adaheads.home> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="3a9bc8da2b28cb09207c678bdb07b736"; logging-data="8032"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/sRX6nE+ZhgUYZNNQQlLtP2CgdprZ0hs=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:f/eVyAa0OpuatwHm50zSSIVcdc4= sha1:MaO0+vUr4W5Y/OD3AP/ITUbX9Z4= Xref: reader02.eternal-september.org comp.lang.ada:54161 Date: 2018-08-13T16:54:26+01:00 List-Id: Simon Wright writes: > AdaMagica writes: > >> Am Sonntag, 12. August 2018 20:51:51 UTC+2 schrieb Simon Wright: >>> AdaMagica writes: >>> >>> > Thank you all for your time to think about this. >>> > >>> > I'll send it in to AdaCore. Hopefully it will be correted next year >>> > in the public version. >>> >>> This is a somewhat artificial error, isn't it? >>> >>> function Maybe (X : Priv) return Subt; >>> ... >>> function Maybe (X : Priv) return Subt is (X); >>> ... >>> X := Maybe (C); -- C is -1 >>> >>> works as we would have expected. >> >> What is it that you expect here? What type is X? I didn't try with >> GNAT, but I would expect Maybe (C) to raise Assertion_Error >> independently of X. > > Oh come on! these are additions to the example that *you* posted upthread. Oops. X is of type Subt. It can get quite misleading to use expression functions when trying to use the debugger to work out where an exception is raised. Given function Maybe (X : Priv) return Subt is begin return X; end Maybe; called as S : Subt := Maybe (-); Maybe happily returns -1 and leaves it up to the assignment to raise the necessary exception. And if the assignment is P : Priv := Maybe (-1); no exception is raised.