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!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: GNAT "alignment value must be positive" Date: Tue, 07 Apr 2015 11:46:58 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <0817bf94-0550-40c4-ba5f-f2ecd6383dbb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 7 Apr 2015 18:46:04 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="3f77efd256cd7097938236a53a6861ee"; logging-data="27750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uO/v1W6ekkVP7MUI2rWkn8WgNCX4AxZQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: Cancel-Lock: sha1:RfSp4Z4bMyp9RK0UULJBfmltRzg= Xref: news.eternal-september.org comp.lang.ada:25452 Date: 2015-04-07T11:46:58-07:00 List-Id: On 04/07/2015 08:27 AM, marciant@earthlink.net wrote: > Additional information: > (1) The alignment clause is for a record type, > (2) Ada95 mode is being used, > > Additional analysis: > GNAT's sem_ch13.adb code unconditionally rejects zero for the alignment and thus seems to unconditionally not support items not necessarily aligned to byte boundaries. If that is the case then it would help if such a decision was documented in GNAT's implementation specific documentation: section 14 of the GNAT reference manual. (Maybe it is elsewhere I missed it. Did I?) The Ada-95 ARM 13.3 includes the statement given earlier for the Alignment attribute: "The value of this attribute is of type universal_integer, and nonnegative; zero means that the object is not necessarily aligned on a storage element boundary." However, note also the additional requirements for a composite type: "If an Alignment is specified for a composite subtype or object, this Alignment shall be equal to the least common multiple of any specified Alignments of the subcomponent subtypes, or an integer multiple thereof." If your record has components with specified non-zero alignment, then the alignment of the record must be non-zero. Finally, J.8 says that for R use record at mod a ... end record; is equivalent to for R'Alignment use a; For R use record ... end record; So zero should be allowed in this obsolescent form as well. If GNAT is rejecting zero when allowed by these rules then it would seem to be a compiler error. -- Jeff Carter "Ada has made you lazy and careless. You can write programs in C that are just as safe by the simple application of super-human diligence." E. Robert Tisdale 72