(j3.2006) VOLATILE or ASYNCHRONOUS function results ??

Bill Long longb
Mon Jan 9 19:01:42 EST 2017


This question came up:  Is it allowed for a function result variable to be declared with the VOLATILE attribute. ( Same general issue with ASYNCHRONOUS).  I don?t see where we specifically disallow VOLATILE, but allowing it seems problematic.  A volatile variable can become undefined by ?unseen? actions and an undefined result variable is a bad thing when the function completes. 

There are places in the standard where we hint that VOLATILE is unexpected for a function result.

At the beginning of the Procedures clause:

Characteristics of procedure arguments include "whether it has the ASYNCHRONOUS (8.5.4), CONTIGUOUS (8.5.7), VALUE (8.5.18), or VOLATILE (8.5.19) attributes,"

whereas

Characteristics of function results include (in the corresponding sentence) "whether it has the CONTIGUOUS attribute,".

This suggests that ASYNCHRONOUS, VALUE, and VOLATILE were not envisioned for function results.  VALUE is specifically prohibited, but ASYNCHRONOUS and VOLATILE are not, are they?


Similarly, in the subclause listing the cases where an explicit interface is required, for dummy arguments, the requirement is

"has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE, or VOLATILE attribute,"

whereas for a function result:

"is a pointer or is allocatable,"

suggesting neither ASYNCHRONOUS nor VOLATILE is envisioned for a function result.


Is there a specific prohibition in the standard disallowing VOLATILE or ASYNCHRONOUS for function results?  If not, should there be?

Cheers,
Bill

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list