From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GNAT "alignment value must be positive"
Date: Fri, 10 Apr 2015 16:18:10 -0500
Date: 2015-04-10T16:18:10-05:00 [thread overview]
Message-ID: <mg9emi$87a$1@loke.gir.dk> (raw)
In-Reply-To: ae527812-cf69-4141-8cdb-7d44f0be19a3@googlegroups.com
<marciant@earthlink.net> wrote in message
news:ae527812-cf69-4141-8cdb-7d44f0be19a3@googlegroups.com...
On Thursday, April 9, 2015 at 8:21:55 PM UTC-4, Randy Brukardt wrote:
...
...
>> > - "zero means that the object is not necessarily aligned on a storage
>> > element
>> > boundary."?
>>
>> That's talking about the value of X'Alignment, when it is *read*, not so
>> much when it is specified. (This is 13.3(23/2)).
>
>But if the "natural"/"default" alignment that an implementation would use
>when it
>places an object of some type is - lets say 2, what about the case that a
>user
>program does unchecked conversion on a sequence of bits to a record type
>that ends up making the alignment of some of the records components not
>have
>the default alignment (not 2 in the example - infact not even alignment 1).
>I thought that this was a case where the user should specify alignment 0
>for the
>component's type and that without doing that, improper reading of the
>component
>by the program might be the result, due to the compiler having assumed that
>the
>component/"object" had its default alignment.
That's clearly target dependent. On the x86 where I've done most of my work,
alignment has no impact on the code (it does have an impact on performance).
Everything is at least byte-aligned (objects are copied to make that so for
parameter passing, and of course, unaligned by-reference objects aren't
allowed), and the machine has no problem with unaligned accesses. (Well,
there are some of the rarely-used vector operations that only work on
aligned data; that's one reason why we don't use them. :-)
There certainly are targets that differ; at least in theory. That's not
surprising, ultimately Chapter 13 is all about target-dependent stuff
anyway. But even then, I'd expect (in your example) the Unchecked_Conversion
to make a copy so the proper alignment is maintained. It's a function after
all, the semantics are that of a copy (there's a permission to make it
by-reference, but an implementor would be silly to use such a permission if
it caused later code problems).
Randy.
next prev parent reply other threads:[~2015-04-10 21:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 20:35 GNAT "alignment value must be positive" 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-04-06 20:16 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox