Even when an explicit interface is known, no warnings are generated when array
argument bounds (available to the compiler) don't match. Consider the
following:
module mod
implicit none
contains
subroutine a(n,v)
integer,intent(in)::n
real,dimension(n),intent(in)::v
write(*,*)v
end subroutine a
subroutine b
real,dimension(5)::v
v=0
call a(8,v(1:4))
end subroutine b
end module mod
When b is being compiled the interface to a is known, yet no warnings are
generated of the obvious mismatch in the arguments (run.f90 just calls b):
$ gfortran -Wall -W -c --std=f2003 --pedantic -fbounds-check -O case.f90
$ gfortran -Wall -W --std=f2003 --pedantic -fbounds-check -O run.f90 case.o
$ ./a.out
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 -1.1411260E-37 1.5604860E-41 -5.1655852E-38 1.5604860E-41
-6.3728095E-38 1.5604860E-41 0.000000 0.000000 5.8804453E-39
0.000000 4.2038954E-45 0.000000 5.8809218E-39 0.000000
-6.3728095E-38 1.5604860E-41 -8.5373851E-38 1.5604860E-41 5.8801398E-39
While this construct is probably legal as a hang-on from crappy old fortran, I
can't think of a situation when giving explicit bounds like this where simply
overrunning would be the desired effect. A warning would be nice.
(I was going to also complain that -fbouns-check didn't come up with anything,
but then I saw PR 27989.)
--
Summary: No warning on bad arguments with explicit interface
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terry at chem dot gu dot se
GCC host triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32317