comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Overriding Default_Component_Value in derived array type
Date: Tue, 21 Apr 2020 21:13:04 +0300
Date: 2020-04-21T21:13:04+03:00	[thread overview]
Message-ID: <hg8rdgFpoa2U1@mid.individual.net> (raw)

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;

       A2 : Arr_2;
       A6 : Arr_6;

Printing out the default values of A2 and A6 I get 2's for both. I 
expected 2's for A2 and 6's for A6, as I read the RM.

Overriding Default_Value for a derived integer type works as expected, 
as does overriding a Default_Value for the component type with a 
Default_Component_Value for the array type.

For the array type derivation, if the parent array type has no 
Default_Component_Value then the Default_Component_Value for the derived 
type is effective. That is, in the above example, if I remove the 
Default_Component_Value from Arr_2, then A2 contains garbage as 
expected, and A6 contains sixes.

Bug or feature?

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

             reply	other threads:[~2020-04-21 18:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 18:13 Niklas Holsti [this message]
2020-04-21 21:32 ` Overriding Default_Component_Value in derived array type Randy Brukardt
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