It seems that the standard (or at least the standard literature) is not clear
on this one, but Sun and Intel compilers agree that it's good.
The problem we have is actually about a derived type that gets two different
alias names in USE/ONLY statements. In the end, it should be treated as two
different types but it is really one implementation.
It works the same with plain integers, so I use these for illustration.
Example program:

module base
        integer :: baseint
end module

module a
        use base, ONLY: aint => baseint
end module

module b
        use base, ONLY: bint => baseint
end module

module c
        use a
        use b
        private
        public :: aint, bint
end module

program user
        use c, ONLY: aint, bint

        aint = 3
        bint = 8
        write(*,*) aint
end program

gfortran (4.1, 4.2, 4.3), and incidentally also g95 (if that interests
anyone;-) refuse this with:
 public :: aint, bint
                    1
Error: ACCESS specification at (1) was already specified

If you just remove the private/public stuff in module c, like that:

module c
        use a
        use b
end module

The code compiles fine and I get the expected output fromt the main program:

           8

...which is the value of baseint, set through bint and read through aint.
It feels like gfortran is too eager in error checking there on harmless code. I
am not sure if this code is strictly Fortran90 conforming... but I read that a
variable is allowed to have different aliases; just didn't find mentioning of
one module making public several of these.


-- 
           Summary: too cautionous alias checking with renamed
                    variables/types from modules (Error: ACCESS
                    specification already specified)
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas dot orgis at awi dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36454

Reply via email to