This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/36947] New: accepts-invalid
- From: "w6ws at earthlink dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jul 2008 03:57:31 -0000
- Subject: [Bug fortran/36947] New: accepts-invalid
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following test case demonstrates a problem with gfortran, and several
other, compilers that are not properly checking intents. This happens when
using an interface block to define a dummy argument for passing subprograms.
The interface of the actual routine being passed is not fully compared to the
dummy argument definition, the code compiles without warning, and bad results
occur at runtime.
NAG is one of a very few compilers that detect the error at run time.
module testsub
contains
subroutine test(sub)
interface
subroutine sub(x)
integer, intent(in), optional:: x
end subroutine
end interface
print *, "In test(), about to call sub()"
call sub()
end subroutine
end module
module sub
contains
subroutine subActual(x)
! actual subroutine's argment is different in intent and optional
integer, intent(inout):: x
print *, "In subActual():", x
end subroutine
end module
program interfaceCheck
use testsub
use sub
integer :: a
call test(subActual)
end program
--
Summary: accepts-invalid
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: w6ws at earthlink dot net
GCC build triplet: Attributes not fully checked comparing actual vs dummy
procedure
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36947