We should consider marking module procedures with PRIVATE attribute as STATIC (in the C sense) such that they can be eliminated. In the following program, "two" could be optimized away as it cannot be called from outside the module. However, this does not happen with
gfortran -O3 -c test.f90 (nor with ifort -O3 -c test, nor for NAG f95, openf95) as "nm test.o" shows. I think STATIC does the right thing also if it is used as in the following example: procedure(), pointer :: ptr ! e.g. dummy argument, module variable, local variable ... ptr => two I think one cannot mark it as STATIC if it has a C binding name, i.e. PRIVATE but bind(C). It can be marked as STATIC, however, if it has no binding name: bind(C,name=""). (Maybe I miss something as this optimization does not happen for so many compilers, but I fail to see the flaw.) MODULE M PRIVATE :: two CONTAINS SUBROUTINE one(a) integer :: a a = two() END SUBROUTINE one integer FUNCTION two() two = 42 END FUNCTION two END MODULE -- Summary: Mark PRIVATE module functions as STATIC to faciliate optimization Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973