This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/28004] New: Warn if intent(out) dummy variable is not set
- From: "tobias dot burnus at physik dot fu-berlin dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jun 2006 20:12:07 -0000
- Subject: [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GNU Fortran 95 (GCC) 4.2.0 20060612.
If I write a program with a intent(out) variable and this varibale is not set,
gfortran only writes:
warning: unused variable C
Expected: Default warning like ifort/NAG f95/g95:
In file ff.f90:7
subroutine sub(a)
1
Warning (158): INTENT(OUT) variable 'a' at (1) is never set
---
Warning: ff.f90, line 11: INTENT(OUT) dummy argument A never set
---
fortcom: Warning: ff.f90, line 7: A dummy argument with an explicit INTENT(OUT)
declaration is not given an explicit value. [A]
subroutine sub(a)
---------------^
Test program:
-----------------
program test
implicit none
real :: a
call sub(a)
end program test
subroutine sub(a)
implicit none
real, intent(out) :: a
print *,a
end subroutine sub
-----------------
If you want, you can also -Wall warn that 'a' is used before it has gotten any
value assiged. (And Fortran does not guarantee for intent(out) that the
variable is set, even if I had add an a = 4.0 before the call sub(a).)
Actually, none of the other compilers detects this at compile time, at run time
NAG f95 (-nan or -C=undefined) does.
--
Summary: Warn if intent(out) dummy variable is not set
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tobias dot burnus at physik dot fu-berlin dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004