This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

public and private access in modules


Hi all.

The code below defines a type t, which is private the module. The
variable instance is public. While the Intel Fortran Compiler
complains that the types instance must be private because its type is,
gfortran happily compiles this code and the binary prints
instance%value to stdout.

Tested with gfortran-4.1.1 and an older checkout of gcc-4.2. I don't
know what the standard recommends. Is this an issue in gfortran or is
ifort overly protective?

Daniel


$> cat pp.f90 MODULE mytype TYPE, PRIVATE :: t INTEGER :: value END TYPE TYPE(t), PARAMETER :: instance = t(1) END MODULE

PROGRAM foo
 USE mytype
 WRITE (*,*) instance%value
END PROGRAM

$> gfortran -w -W -Wall -Wimplicit-interface -Wconversion \
                   -Wnonstd-intrinsics  -Wsurprising  -Wunderflow \
                   -Wunused-labels -Wline-truncation -pedantic pp.f90
$> ./a.out
          1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]