[Bug fortran/33298] Wrong code for SPREAD on dummy arguments
jpr at csc dot fi
gcc-bugzilla@gcc.gnu.org
Tue Sep 4 07:49:00 GMT 2007
------- Comment #1 from jpr at csc dot fi 2007-09-04 07:49 -------
The code is invalid without explicit interface to SUB().
Modified code:
REAL X(2,3), Y(2)
Y=[1.,2.]
CALL SUB(X,Y)
DO I = 1, 3
PRINT*,X(:,I)
ENDDO
CONTAINS
SUBROUTINE SUB(A,B)
REAL A(:,:), B(:)
A(:,:) = SPREAD(B(:),2,SIZE(A,2))
END SUBROUTINE SUB
END
works just fine. Alternatively
REAL X(2,3), Y(2)
Y=[1.,2.]
CALL SUB(X,Y,size(y,1),size(y,2))
DO I = 1, 3
PRINT*,X(:,I)
ENDDO
END
SUBROUTINE SUB(A,B,n,m)
INTEGER n,m
REAL A(n,m), B(n)
A(:,:) = SPREAD(B(:),2,SIZE(A,2))
END
also works as expected.
If the main program and SUB are compiled together, the compiler could
of course diagnose this, as e.g. pathscale does:
SUBROUTINE SUB(A,B)
^
pathf95-1277 pathf90: ERROR SUB, File = t.f90, Line = 9, Column = 18
Procedure "SUB" is referenced at line 3 (t.f90). It must have an explicit
interface specified.
Regards, Juha
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33298
More information about the Gcc-bugs
mailing list