This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
public and private access in modules
- From: "Daniel Franke" <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 22 Aug 2006 12:21:38 +0200
- Subject: public and private access in modules
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=boqGgIlkSd5i334cR7hB9WqNaUm1pVQglhbieip/XXey7iEzu8cn/SIMVRJv1GTIDFxAbtT35+bALtzR63u/bAJIJI/SyJHth76zWoc7ILddripNLEoPxFdIWwP1qxYJeTd+zHwubkhAvA75mNsK0TuwaaVkFj97oUpiTzQqV0A=
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