This is not a bug report, since I cannot determine what a standard conforming compiler should actually do with this code. So it's a puzzle for those that like that kind of thing.
module kind_mod
implicit none
integer, parameter :: dp = kind(1.d0)
end module kind_mod
module x_mod
use kind_mod
implicit none
real(dp) :: a = 1.d0
end module x_mod
module y_mod
use x_mod
implicit none
private
public b ! Only b is public, not clear to me if a from x_mod or dp from kind_mod
! should be visible from the main program that uses y_mod
real(dp) :: b = 2.d0
end module y_mod
program main
use y_mod
print*, a ! FTN95 prints the correct value, is this correct?
print*, b
print*, dp ! FTN95 prints the correct value, is this correct?
end program main
! AI analysis
! Visibility of a:
! a is defined in x_mod and x_mod is used in y_mod. However, because y_mod declares private,
! everything in x_mod (including a) should be private unless explicitly made public in y_mod.
! Since a is not listed as public, it is not visible in main.
! Attempting to print a should cause a compilation error.
!
! Visibility of b:
! b is explicitly made public in y_mod, so it is visible in main and should print the value
! of 2.0.
!
! Visibility of dp:
! dp is defined in kind_mod and is used by x_mod. x_mod is used by y_mod. While dp is
! publicly accessible in kind_mod, it is not made private anywhere. Since y_mod does not
! explicitly hide it, dp should be visible in main and should print the kind value for
! double precision, which is typically 8.
!
! If the compiler adheres strictly to the Fortran standard: Attempting to access a would
! result in a compilation error, and the program would not compile due to a being private.
!