From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Overriding Default_Component_Value in derived array type
Date: Tue, 21 Apr 2020 16:32:48 -0500
Date: 2020-04-21T16:32:48-05:00 [thread overview]
Message-ID: <r7noq1$c5r$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: hg8rdgFpoa2U1@mid.individual.net
"Niklas Holsti" <niklas.holsti@tidorum.invalid> 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.
next prev parent reply other threads:[~2020-04-21 21:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 18:13 Overriding Default_Component_Value in derived array type Niklas Holsti
2020-04-21 21:32 ` Randy Brukardt [this message]
2020-04-24 21:09 ` Niklas Holsti
2020-04-28 5:43 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox