* Pack aspect with aliased component.
@ 2025-03-02 9:29 Blady
2025-03-02 11:33 ` Jeffrey R.Carter
0 siblings, 1 reply; 3+ messages in thread
From: Blady @ 2025-03-02 9:29 UTC (permalink / raw)
Hello,
With the following AARM example:
14.e/3 {AI05-0229-1} procedure Q is
use P1, P2;
type Array1 is array(Integer range <>) of aliased S1
with Pack; -- warning: cannot pack aliased
components (RM 13.2(7))
GNAT issues the warning in comment above.
Mentions of aliased in following AARM paragraphs are not so clear for me:
13.2 Packed Types
7.1/4 * {AI12-0001-1} Any component of a packed type that is of a
by-reference type, that is specified as independently
addressable, or
that contains an aliased part, shall be aligned according to the
alignment of its subtype.
9.c/3 {AI95-00291-02} {AI05-0229-1} Added clarification that the Pack
aspect can ignore alignment requirements on types that
don't have
by-reference or aliased parts. This was always intended,
but there
was no wording to that effect.
What is correct ?
Why packed type couldn't have aliased components?
Thanks, Pascal.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Pack aspect with aliased component.
2025-03-02 9:29 Pack aspect with aliased component Blady
@ 2025-03-02 11:33 ` Jeffrey R.Carter
2025-03-06 20:52 ` Blady
0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey R.Carter @ 2025-03-02 11:33 UTC (permalink / raw)
On 2025-03-02 10:29, Blady wrote:
>
> With the following AARM example:
> 14.e/3 {AI05-0229-1} procedure Q is
> use P1, P2;
> type Array1 is array(Integer range <>) of aliased S1
> with Pack; -- warning: cannot pack aliased components (RM
> 13.2(7))
>
> GNAT issues the warning in comment above.
>
> Why packed type couldn't have aliased components?
This is a warning, not an error. The compiler has accepted the declaration and
you can use it.
Remember that Pack is a suggestion to the compiler, not a requirement, and the
compiler can ignore it, or pack things less tightly than you might like.
An aliased component may be accessed through an alias (access value), and that
access will not know that the component has been packed, and so access memory
belonging to other components as well. For this reason, aliased components
cannot be packed.
You can specify Component_Size for the type; the compiler must either be able to
make the components that size, or reject the declaration. Specifying a
Component_Size for an aliased component that makes the component smaller than a
stand-alone object of the type will be rejected.
--
Jeff Carter
"I've seen projects fail miserably for blindly
applying the Agile catechism: we're Agile, we
don't need to stop and think, we just go ahead
and code!"
Bertrand Meyer
150
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Pack aspect with aliased component.
2025-03-02 11:33 ` Jeffrey R.Carter
@ 2025-03-06 20:52 ` Blady
0 siblings, 0 replies; 3+ messages in thread
From: Blady @ 2025-03-06 20:52 UTC (permalink / raw)
Le 02/03/2025 à 12:33, Jeffrey R.Carter a écrit :
> On 2025-03-02 10:29, Blady wrote:
>>
>> With the following AARM example:
>> 14.e/3 {AI05-0229-1} procedure Q is
>> use P1, P2;
>> type Array1 is array(Integer range <>) of aliased S1
>> with Pack; -- warning: cannot pack aliased
>> components (RM 13.2(7))
>>
>> GNAT issues the warning in comment above.
>>
>> Why packed type couldn't have aliased components?
>
> This is a warning, not an error. The compiler has accepted the
> declaration and you can use it.
>
> Remember that Pack is a suggestion to the compiler, not a requirement,
> and the compiler can ignore it, or pack things less tightly than you
> might like.
>
> An aliased component may be accessed through an alias (access value),
> and that access will not know that the component has been packed, and so
> access memory belonging to other components as well. For this reason,
> aliased components cannot be packed.
>
> You can specify Component_Size for the type; the compiler must either be
> able to make the components that size, or reject the declaration.
> Specifying a Component_Size for an aliased component that makes the
> component smaller than a stand-alone object of the type will be rejected.
Thanks Jeff, your explanation seems to me clearer than the AARM ;)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-06 20:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02 9:29 Pack aspect with aliased component Blady
2025-03-02 11:33 ` Jeffrey R.Carter
2025-03-06 20:52 ` Blady
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox