(j3.2006) Is this allowed?
Van Snyder
Van.Snyder
Fri Aug 16 19:27:39 EDT 2013
This is prohibited by C558:
subroutine S1 ( A )
integer, value, volatile :: A
print *, a
end subroutine S1
This, which is more wordy than S1 but identical in functionality, is
allowed:
subroutine S2 ( A )
integer, intent(in) :: A
integer, volatile :: B
b = a
print *, b
end subroutine S2
Is this allowed?
subroutine S3 ( A )
integer, value :: A
block
volatile :: A
print *, a
end block
end subroutine S3
The VOLATILE attribute in S3 appears to be prohibited in C558, but the
only processor I have that understands the BLOCK construct says nothing.
VALUE is not mentioned in 5.3.19 (especially not in C559). 5.3.19p2
says
Within a BLOCK construct, a noncoarray object may have the
VOLATILE attribute even if it does not have the attribute
outside the BLOCK construct.
The word "may" explicitly confers permission for the VOLATILE attribute.
There's nothing in this sentence about the object not having the VALUE
attribute. Does this contradict C558, or does A no longer have the
VALUE attribute within the BLOCK construct (and where does it say
that!)?
8.1.4p2 says
The appearance of the name of an object that is not a construct
entity in an ASYNCHRONOUS or VOLATILE statement in a BLOCK
construct specifies that the object has the attribute within the
construct even if it does not have the attribute outside the
construct.
Again, there's no exception if the object has the VALUE attribute.
Within the BLOCK construct, does A still have the VALUE attribute? I
couldn't find any text that makes it go away.
How about this one?
subroutine S4 ( A )
integer, value :: A
call T
contains
subroutine T
volatile :: A
print *, a
end subroutine T
end subroutine S4
Two of my processors are perfectly happy with it, but one complains.
16.5.1.4p1 says "... a noncoarray local entity may have the VOLATILE
attribute even if the host entity does not." Again, "may" explicitly
confers permission, and there's no exception if the object has the VALUE
attribute. Does this contradict C558, or does A no longer have the
VALUE attribute within the internal subroutine (and where does it say
that!)?
If S3 and S4 are allowed but S1 isn't, did we really intend this
inconsistency?
If we didn't intend these to be inconsistent, do we remove VOLATILE from
C558, add "without the VALUE attribute" in 5.3.19p2, 8.1.4p2, and
16.5.1.4p1, or do nothing?
If we intended these to be inconsistent, should we prefix "Within the
scoping unit where it is declared" to C558, so as not to be contradicted
in 5.3.19p2, 8.1.4p2, and 16.5.1.4p1?
More information about the J3
mailing list