This test is taken from
http://ftp.cac.psu.edu/pub/ger/fortran/test/
$ cat test.f90
MODULE all_sub
PRIVATE
PUBLIC :: test1,test2
CONTAINS
SUBROUTINE test1(a,n)
IMPLICIT NONE
INTEGER,INTENT(in) :: n
REAL,INTENT(out), DIMENSION(n) :: a
REAL :: b
WRITE(*,*) 'Problem with intent(out) checkable at compile time'
!---Elements of array, a, have not yet been "defined within Subroutine
! test1." The following line violates Fortran 90 Standard 5.1.2.3
! Intent Attribute.
b=a(2)
WRITE(*,*) b
a(:)=4.
END SUBROUTINE test1
SUBROUTINE test2(a,n,code)
IMPLICIT NONE
INTEGER,INTENT(in) :: n
REAL, INTENT(out), DIMENSION(n) :: a
LOGICAL, INTENT(in) :: code
REAL :: b
IF (code) THEN
WRITE(*,*) 'Problem with intent(out) checkable at run time'
!---Elements of array, a, have not yet been "defined within Subroutine
! test1." The following line violates Fortran 90 Standard 5.1.2.3
! Intent Attribute.
b=a(2)
WRITE(*,*) b
END IF
a(:)=4.
END SUBROUTINE test2
END MODULE all_sub
PROGRAM tintent2
USE all_sub, ONLY : test1, test2
IMPLICIT NONE
INTEGER, PARAMETER :: n=7
REAL, DIMENSION(n) :: a
a(:)=10.
CALL test1(a,n)
CALL test2(a,n,.TRUE.)
pause
END PROGRAM tintent2
$ gfortran test.f90
$ ./a.out
Problem with intent(out) checkable at compile time
10.00000
Problem with intent(out) checkable at run time
4.000000
PAUSE
To resume execution, type go. Other input will terminate the job.
go
RESUMED
This should have given following error (compile time)
The variable (a(2)) has an undefined value.
--
Summary: compiles invalid-code
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uttamp at us dot ibm dot com
GCC build triplet: powerpc64-linux
GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24884