https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64118
Bug ID: 64118 Summary: Strange warning about unused function/subroutine Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: angelo.graziosi at alice dot it Created attachment 34144 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34144&action=edit Tar archive with source code With the attached tests I get the following warning: $ gfortran -Wall test_unused_func.f90 -o test_unused_func.out test_unused_func.f90:54:0: warning: ‘f’ defined but not used [-Wunused-function] real(dp) function f(x) result(y) ^ $ gfortran -Wall test_unused_sub.f90 -o test_unused_sub.out test_unused_sub.f90:44:0: warning: ‘sub3’ defined but not used [-Wunused-function] subroutine sub3() ^ test_unused_sub.f90:40:0: warning: ‘sub2’ defined but not used [-Wunused-function] subroutine sub2() ^ test_unused_sub.f90:36:0: warning: ‘sub1’ defined but not used [-Wunused-function] subroutine sub1() ^ which I find a bit "strange": after all, the function f() in the first test, for example, is used because it is passed to the call of simpson().. and indeed $ ./test_unused_func.out 1.4250604553524227 1.9202581413298656 confirming it is _used_! I found this using gfortran from GCC: 4.8.2 (MSYS2 64), 4.8.3 (OSX+MacPorts 64, Cygwin64), 4.9.1 (MSYS2+MinGW64), but maybe also recent versions of gfortran are affected. The tests are archived in the attached tar-ball. See also the discussion on gfortran mailing list: https://gcc.gnu.org/ml/fortran/2014-07/msg00168.html https://gcc.gnu.org/ml/fortran/2014-11/msg00143.html Ciao, Angelo.