TREE_PUBLIC for module symbols?

Paul Richard Thomas paul.richard.thomas@gmail.com
Wed Jul 1 10:42:00 GMT 2015


Dear Tobias,

Following the latest version of my submodule patch, I have managed to
overcome the difficulty of making private symbols available to
submodules in a reasonably economical fashion. Of course, the solution
makes these symbols visible in the module file, albeit in a different
section to public symbols.

Since private symbols are now visible in the module files, the meaning
or usefulness of privacy becomes rather moot, as already discussed on
the list. This conundrum is made still worse because module variables
have to be set TREE_PUBLIC, otherwise they disappear at any level of
optimization and leave the linker complaining verbosely.

Consider an example:
module foo

  private

  public bar

  integer :: a = 1

  interface
    module subroutine bar
    end subroutine
  end interface

contains
end module

submodule(foo) fooson

contains
  module subroutine bar
    print *, a
    a = a+1
  end subroutine
end submodule

program test
  use foo
  call bar
  call bar
  call bar
  call bar
  call bar
end program test

Unless 'a' is forced to be TREE_PUBLIC the link stage fails at -O1 and
above. Is there an alternative to TREE_PUBLIC? If not, what are the
ramifications of making all module entities TREE_PUBLIC?

With best regards

Paul



More information about the Fortran mailing list