comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GNAT "alignment value must be positive"
Date: Wed, 8 Apr 2015 15:18:45 -0500
Date: 2015-04-08T15:18:45-05:00	[thread overview]
Message-ID: <mg42f5$sba$1@loke.gir.dk> (raw)
In-Reply-To: mg18lb$r36$1@dont-email.me

"Jeffrey Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:mg18lb$r36$1@dont-email.me...
...
> 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.

This requirement is nonsense and was deleted from the language for Ada 2005. 
And few compilers ever enforced it (Janus/Ada did, but GNAT did not, so far 
as I know). It probably would have been deleted sooner had I asked about it 
rather than just implementing it as the rule. The intent is that any 
"inherited" properties can always be overridden by a explicitly specified 
property.

...
> 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.

I don't think Janus/Ada allows specifying zero, but that makes some sense as 
no stand-alone object could ever be allocated at a non-byte-aligned address. 
Nor would that ever happen for a component in the absence of some other 
representation item. So there is nothing that could actually be aligned as 
"zero". Perhaps GNAT is making the same assumption.

0 is defined as a possible alignment so that the alignment of a bit-mapped 
component is meaningful (we can't have 'Alignment not meaning anything). But 
I don't know of any reason to specify the alignment as zero, everything is 
always byte allocated by default. There might be some machine on which it 
makes sense to not byte align by default, but I haven't encountered it to 
date.

                                          Randy.


  parent reply	other threads:[~2015-04-08 20:18 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
2015-04-07 19:45     ` marciant
2015-04-08 20:18     ` Randy Brukardt [this message]
  -- 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