------- Comment #2 from burnus at gcc dot gnu dot org 2010-02-20 22:08 ------- Marking it as STATIC will become difficult with SUBMODULES as one has several .o files belonging to one common MODULE, i.e. the function shall be accessible by all submodules, which are scattered over several .o files.
With -flto -fwhole-program it should be possible to optimize the function away even without using STATIC. (In reply to comment #1) > How about this (somewhat constructed) example: I fail to see why __m_MOD_two is needed - it is not called anywhere. > ! interface module, file (a) > MODULE M > PRIVATE :: two [...] > integer FUNCTION two() [...] > END MODULE > ! implementation, file (b) > SUBROUTINE one(a) > USE M > integer :: a > a = two() > END SUBROUTINE one You are calling "two_" which is a REAL function and you are not calling an INTEGER function and specifically you are not calling __m_MOD_two. "two" is just an implicitly type external function. > SUBROUTINE three(a) > integer :: a > a = two() > END SUBROUTINE three This one should be identical to "one". > I often use modules simply to provide interfaces for subroutines implemented > in other files and compiled into libraries You should use ABSTRACT INTERFACE to provide interfaces... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973