From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Did I find a bug here? Date: Fri, 2 Apr 2021 09:30:34 +0200 Organization: Adalog Message-ID: References: <6901cec3-b7b1-48c8-98fe-0360572175c2n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 2 Apr 2021 07:30:34 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="6d1ab59770eee54f079e0183b73f12d7"; logging-data="12374"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zPCN9yXFnfPyn0uVe3wbo" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 Cancel-Lock: sha1:oByPonc/pEvyfIXnKMQ8M2mJKzk= In-Reply-To: <6901cec3-b7b1-48c8-98fe-0360572175c2n@googlegroups.com> Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:61727 List-Id: Le 02/04/2021 à 08:30, reinert a écrit : > Assume this simple program: > > procedure test0 is > type ABC_Type is (A,B,C); > subtype AB_Type is ABC_Type with Static_Predicate => AB_Type in A | B; > X : ABC_type := A; > begin > -- alternative 1: > case AB_Type(X) is > when A => null; > when B => null; > when others => null; -- ??? should the compiler complain here? > end case; > --alternative 2: > case AB_Type(X) is > when A => null; > when B => null; > end case; > end test0; > > Should the compiler complain about "when others => null" here? > My compiler does not (running debian 10, updated, gnat-8). > I find it strange that both alternatives goes through. > A case statement is allowed to have alternatives that cover no value. A friendly compiler can warn you that "this branch covers no value", but what you wrote is not illegal (and sometimes useful, if you have variants of your software that use slightly different definitions of the type). -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr