comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: GNAT "alignment value must be positive"
Date: Tue, 07 Apr 2015 11:46:58 -0700
Date: 2015-04-07T11:46:58-07:00	[thread overview]
Message-ID: <mg18lb$r36$1@dont-email.me> (raw)
In-Reply-To: <d3ba102f-5e0a-4732-865b-a79d3bfee12b@googlegroups.com>

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

  reply	other threads:[~2015-04-07 18:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-06 20:16 GNAT "alignment value must be positive" marciant
2015-04-06 20:48 ` Shark8
2015-04-07 15:28   ` marciant
2015-04-07 15:27 ` marciant
2015-04-07 18:46   ` Jeffrey Carter [this message]
2015-04-07 19:45     ` marciant
2015-04-08 20:18     ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2015-04-08 20:35 Randy Brukardt
2015-04-09 13:28 ` marciant
2015-04-10  0:21   ` Randy Brukardt
2015-04-10 15:45     ` marciant
2015-04-10 21:18       ` 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