From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Ada array contiguity. Date: Mon, 20 Feb 2023 08:12:41 +0100 Organization: Adalog Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 20 Feb 2023 07:12:36 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="cb32f51e92c92af3b69c3041a7dc7531"; logging-data="739403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rhHozos1SH92sX338paTc" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cancel-Lock: sha1:KT73SLBL6wRymeq98kQ81IpmSIg= In-Reply-To: Content-Language: en-US, fr Xref: reader01.eternal-september.org comp.lang.ada:64949 List-Id: Le 19/02/2023 à 18:54, Niklas Holsti a écrit : > On 2023-02-19 19:10, J-P. Rosen wrote: >> Le 19/02/2023 à 15:59, Niklas Holsti a écrit : >>> Indeed. But it seems to me that Arr'Size = Arr'Length * Comp'Size is >>> the meaning usually intended for programming purposes. >> >> Certainly not if Comp'Size is not an integer number of bytes. > > I'm not so certain. By choosing various roundings-up of the component > size, you can choose between "bit-contiguous", "byte-contiguous", etc. > > For example, bit-contiguous with 2-bit components: > >    type Comp is (A, B, C, D) with Size => 2; > >    type Arr is array (1 .. 10) of Comp >       with Pack, Size => 10 * Comp'Size; > > Nybble-contiguous with Comp'Size => 4, byte- (octet-) contiguous with > Comp'Size => 8, etc. > Of course, if you add representation clauses, the compiler will obey them. But the OP's question was whether it was /guaranteed/ to have contiguous representation, and the answer is no - for good reasons. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX https://www.adalog.fr https://www.adacontrol.fr