Version 1.1 of ais/ai-00272.txt

Unformatted version of ais/ai-00272.txt version 1.1
Other versions for file ais/ai-00272.txt

!standard C.06 (07)          01-09-05 AI95-00272/00
!class binding interpretation 01-09-05
!status received 01-08-21
!qualifier Error
!priority Medium
!difficulty Medium
!subject Pragma Atomic and slices
!summary
!question
RM95 C.6(7) states that "An atomic object (including a component) is one to which a pragma Atomic applies, or a component of an array to which a pragma Atomic_Components applies, or any object of an atomic type." "Any object" includes a slice (see RM95 3.3(12)).
Consider for instance:
type A is array (1..4) of Character; pragma Atomic (A); -- Supported?
X : A;
On a 32-bit machine, you would think that supporting pragma Atomic on this type is straightforward, until you realize that "any object" includes a slice like X(1..3), which is impossible to access atomically unless the machine also has 24-bit instructions, which is unlikely to say the least.
!recommendation
!wording
!discussion
!corrigendum xx.xx(xx)
Replace the paragraph:
by:
!ACATS test
!appendix

From: Pascal Leroy
Sent: Tuesday, August 21, 2001 4:03 AM

I am in the process of beefing up support for pragma Atomic in our compiler,
and I am running into what I believe to be a problem in the definition of
that pragma for arrays.

RM95 C.6(7) states that "An atomic object (including a component) is one to
which a pragma Atomic applies, or a component of an array to which a pragma
Atomic_Components applies, or any object of an atomic type."  It is the last
part of this sentence that is bothering me, because "any object" includes a
slice (see RM95 3.3(12)).

Consider for instance:

    type A is array (1..4) of Character;
    pragma Atomic (A); -- Supported?

    X : A;

On a 32-bit machine, you would think that supporting pragma Atomic on this
type is straightforward, until you realize that "any object" includes a
slice like X(1..3), which is impossible to access atomically unless the
machine also has 24-bit instructions, which is unlikely to say the least.

This would seem to make it impossible to support pragma Atomic on arrays
with Length > 2, so surely we have a problem somewhere...

****************************************************************

From: Robert Duff
Sent: Sunday, August 26, 2001 3:52 PM

> This would seem to make it impossible to support pragma Atomic on arrays
> with Length > 2, so surely we have a problem somewhere...

Surely slices should behave like components here.  That is,
a component or slice of an atomic thing is not necessarily
atomic.  I agree with Pascal that there's a problem with the
RM wording, here.

****************************************************************

From: Robert Dewar
Sent: Sunday, August 26, 2001 4:00 PM

Right, obviously slices of atomic arrays are not atomic in general, so this
is just an RM word play excercdise to fix this so that the bug in the RM
is dealt with, I see no impact on the language, since the intent is
obvious.

****************************************************************

From: Pascal Leroy
Sent: Monday, August 27, 2001 2:59 AM

> Surely slices should behave like components here.  That is,
> a component or slice of an atomic thing is not necessarily
> atomic.  I agree with Pascal that there's a problem with the
> RM wording, here.

There is one subtlety, though.  If the first subtype is unconstrained, then
you do not necessarily know whether you are operating on a slice or the
whole array (think of a parameter of the unconstrained first subtype, and
try to generate code for the subprogram body).

This might be a red herring, though, as I don't see what could possibly be
the meaning of Atomic for unconstrained first subtypes (we certainly don't
plan to support this case).

****************************************************************

From: Robert Dewar
Sent: Sunday, August 26, 2001 4:49 AM

It *is* a red herring :-)

****************************************************************

Questions? Ask the ACAA Technical Agent