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!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Overriding Default_Component_Value in derived array type Date: Sat, 25 Apr 2020 00:09:51 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 5NqMEufMPboPhXyNcW9lvAO7jAM4gZjtYoN0iBmyNnoKURjuD8 Cancel-Lock: sha1:DR/vhZ1tMRYY3ltf7vMi2fDr2Ps= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:58486 Date: 2020-04-25T00:09:51+03:00 List-Id: On 2020-04-22 0:32, Randy Brukardt wrote: > "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.) Yes. (Just for the record, I wasn't doing this for a real application, but to support some discussions I was having about initialization in various languages -- C, Ada, Java.) > We're talking about repealing 13.1(10), which will make it more > necessary for compilers to get this sort of stuff right. Oh. Sounds complex, if an inherited primitive operation should use the default component value of its actual argument type, while sharing code with other parent and derived types ... perhaps a hidden parameter would be needed? >> Bug or feature? > > Surely bug. Thanks. I'll consider submitting a bug report to AdaCore. > If one didn't give the Default_Component_Value aspect, then of > course the value would inherit. Yes, and I saw that happen in another test. Moreover, if I remove the parent type's Default_Component_Value aspect, then the aspect in the derivation takes effect. > But be careful that you're not using an inherited routine (that would > of course use the value for it's own type). Would that happen (inherited routine using the value for its own type) even if you repeal 13.1(10)? > 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. So AdaCore already know about this bug, and perhaps others? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .