http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Summary: Spurious "unused-variable" warnings for COMMON block
module variables.
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: [email protected]
ReportedBy: [email protected]
As of gfortran 4.6, module variables that are also part of a common block cause
spurious "unused variable" warnings. The following example
module foo
implicit none
integer:: a, b
common a
end module foo
produces:
$ gfortran -c -Wall test.f90
test.f90:3:0: warning: ‘a’ defined but not used [-Wunused-variable]
Although common variables are deprecated they're still commonly used in
libraries such as mpi and petsc to define some global paramaters. I therefore
get quite a few warning messages in every module that uses these (and also
everywhere module that subsequently uses such modules). Example here with
openmpi:
$ cat test.f90
module foo
use mpi
use petsc
end module
$ mpif90 -I/usr/lib/petscdir/3.1/linux-gnu-c-opt/include/ -Wall -c test.f90
test.f90:2:0: warning: ‘mpi_argv_null’ defined but not used
test.f90:2:0: warning: ‘mpi_in_place’ defined but not used
test.f90:2:0: warning: ‘mpi_status_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_statuses_ignore’ defined but not used
test.f90:3:0: warning: ‘petsc_comm_self’ defined but not used
test.f90:3:0: warning: ‘petsc_null_integer’ defined but not used
test.f90:3:0: warning: ‘petsc_null’ defined but not used
test.f90:3:0: warning: ‘petsc_null_scalar’ defined but not used
test.f90:3:0: warning: ‘petsc_null_double’ defined but not used
test.f90:3:0: warning: ‘petsc_null_real’ defined but not used
test.f90:3:0: warning: ‘petsc_null_truth’ defined but not used
test.f90:2:0: warning: ‘mpi_argvs_null’ defined but not used
test.f90:3:0: warning: ‘petsc_null_object’ defined but not used
test.f90:3:0: warning: ‘petsc_comm_world’ defined but not used
test.f90:2:0: warning: ‘mpi_argv_null’ defined but not used
test.f90:2:0: warning: ‘mpi_argvs_null’ defined but not used
test.f90:2:0: warning: ‘mpi_bottom’ defined but not used
test.f90:2:0: warning: ‘mpi_errcodes_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_in_place’ defined but not used
test.f90:2:0: warning: ‘mpi_status_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_statuses_ignore’ defined but not used
test.f90:3:0: warning: ‘petsc_null_character’ defined but not used
test.f90:2:0: warning: ‘mpi_bottom’ defined but not used
test.f90:2:0: warning: ‘mpi_errcodes_ignore’ defined but not used