The following program compiles in gfortran. I don't know how easily it could be detected, but defining a scalar and using it as an array should be detectable? For what it is worth: ifort also does not detect this error. Changing the "integer :: j = 1" into "integer :: j; j = 1" causes gfortran to emit an error: "Unexpected STATEMENT FUNCTION statement" (and also ifort now writes: "This name has not been declared as an array or a function.") ------------------------ program bug implicit none real :: del integer :: j = 1 del(j)=sin(10.0) print *, del(3) end ------------------------
Tobias, The code is valid fortran in that "del(j) = sin(10)" is a statement function. Putting any executable line before that line (such as j = 1) causes an error to be emitted. If you look at the -fdump-parse-tree you'll see symtree: del Ambig 0 symbol del (REAL 4)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS STATEMENT-PROC FUNCTION) value: -5.44021130e-1 result: del Formal arglist: j I think the bug should be closed as INVALID.
Yes, you are right. I somehow missed those. "12.5.4 Statement function A statement function is a function defined by a single statement. R1238 stmt-function-stmt is function-name ( [ dummy-arg-name-list ] ) = scalar-expr"