This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33298] Wrong code for SPREAD on dummy arguments
- From: "jpr at csc dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Sep 2007 07:49:04 -0000
- Subject: [Bug fortran/33298] Wrong code for SPREAD on dummy arguments
- References: <bug-33298-109@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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