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!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Overriding Default_Component_Value in derived array type Date: Tue, 21 Apr 2020 16:32:48 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Tue, 21 Apr 2020 21:32:50 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="12475"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:58457 Date: 2020-04-21T16:32:48-05:00 List-Id: "Niklas Holsti" wrote in message news:hg8rdgFpoa2U1@mid.individual.net... > I'm seeing behaviour that looks strange to me when I derive an array type > from another and use a Default_Component_Value aspect that tries to > override the corresponding aspect of the parent type. The parent's default > value is used also for the derived type, that is, the aspect definition > for the derived type has no effect, it seems. > > This is on macOS Mojave (10.14.6), GNAT Community 2019 (20190517-83). > > An example: > > type Number is range 1 .. 15; > > type Arr_2 is array (3 .. 5) of Number > with Default_Component_Value => 2; > > type Arr_6 is new Arr_2 > with Default_Component_Value => 6; This is usually illegal by 13.1(10), so it is very rarely done. (If there are any subprograms for Arr_2, then Arr_6 is illegal.) We're talking about repealing 13.1(10), which will make it more necessary for compilers to get this sort of stuff right. ... > Bug or feature? Surely bug. If one didn't give the Default_Component_Value aspect, then of course the value would inherit. But be careful that you're not using an inherited routine (that would of course use the value for it's own type). BTW, my understanding is that AdaCore is reworking Default_Value and Default_Component_Value because some silly person (that would be me) wrote a bunch of ACATS tests for those aspects. (That's why the request came in to repeal 13.1(10)). The next version is likely to be better. Randy.