(j3.2006) (SC22WG5.3682) [ukfortran] N1755: Request for new features from MPI Forum

Robert Corbett Robert.Corbett
Thu Nov 13 21:10:36 EST 2008

Bill Long wrote:
> Robert Corbett wrote:
>> The committe might have intended PROTECTED to be something other than
>> a promise made by the programmer, but the standard as written makes it
>> exactly that.  Just because INTENT(IN) has a similar defect does not
>> make it any the less true.
>> The standard as written allows a compiler to assume that a variable
>> that has the PROTECTED attribute is not definable outside the module,
>> but it allows programs to be written that define the variable outside
>> of the module and it does not require the processor to detect the error.
>> If a programmer writes a program that defines the variable outside the
>> module, it is not a standard-conforming program, and so a
>> standard-conforming processor is free to do anything whatever when
>> compiling or executing the program.  The onus is on the programmer to
>> avoid defining the variable outside the module.
> The first sentence says the standard allows a programmer to do X.  The 
> second one seems to say that IF the programmer does X, the program is 
> not standard conforming.   That seems a bit contradictory.

I shall attempt to state it more clearly.

Programs can be written that are not standard-conforming, but a compiler
cannot practically detect that they are not standard conforming.  In
particular, violations of the restrictions imposed on deinition of a
variable with the PROTECTED attribute cannot be detected in all cases.
Thus, the standard effectively requires a processor to successfully
compile programs that are not standard conforming to avoid rejecting
some programs that are standard conforming.

I can easily imagine a scheme for detecting abuse of variables with the
PROTECTED attribute at run-time, but only at a prohibitive cost.

Bob Corbett

More information about the J3 mailing list