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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Problem with Position of the enumeration Type Date: Wed, 23 Jan 2019 22:35:42 +0000 Organization: A noiseless patient Spider Message-ID: References: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="5df60c48b299959a20b2371e8012729a"; logging-data="26360"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ibgia/Q82hfWPf6d8/vf44Rm8aBZe+bk=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:U7jKBJwNTCDqFuynhuzqGafuowA= sha1:Rg7NHL2Rld3SQ7KS8yAjYLUMa+4= Xref: reader01.eternal-september.org comp.lang.ada:55346 Date: 2019-01-23T22:35:42+00:00 List-Id: Niklas Holsti writes: > Such rules also commonly say that such types should not be used as > array index types, because of the possible introduction of gaps in the > array representations. Not, it seems, with GNAT: $ cat gappy.adb with Ada.Text_IO; use Ada.Text_IO; procedure Gappy is type E_Test is (Pos10, Pos11, Pos12, Pos13, Pos14); for E_Test use (Pos10 => 100, Pos11 => 110, Pos12 => 120, Pos13 => 130, Pos14 => 255); type Arr is array (E_Test) of Integer; begin Put_Line ("Arr's size is" & Arr'Max_Size_In_Storage_Elements'Img & " bytes."); end Gappy; $ gnatmake -f gappy gcc -c gappy.adb gnatbind -x gappy.ali gnatlink gappy.ali $ ./gappy Arr's size is 20 bytes. I'd think any other behaviour would be unreasonable (though I can't see any statement about it in the ARM).