[Bug fortran/38657] New: [Regression, 4.4, 4.3] PUBLIC/PRIVATE Common blocks
pault at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sun Dec 28 23:09:00 GMT 2008
$cat test3.f90
MODULE TEST3
PRIVATE
CHARACTER(LEN=80) :: TESTCHAR
INTEGER :: TESTINT
REAL :: TESTREAL
COMMON /TESTCOMMON1/ TESTCHAR
COMMON /TESTCOMMON2/ TESTINT
COMMON /TESTCOMMON3/ TESTREAL
END MODULE TEST3
$cat test2.f90
MODULE TEST2
USE TEST3
PRIVATE
CHARACTER(LEN=80) :: TESTCHAR
INTEGER :: TESTINT
REAL :: TESTREAL
COMMON /TESTCOMMON1/ TESTCHAR
COMMON /TESTCOMMON2/ TESTINT
COMMON /TESTCOMMON3/ TESTREAL
PUBLIC TESTCHAR
END MODULE TEST2
$cat test1.f90
PROGRAM TEST1
USE TEST2
WRITE(*,*) TESTCHAR
END PROGRAM TEST1
then when I compile it with gfortran it get the following problem
$gfortran -o test3.o -g -c test3.f90
$gfortran -o test2.o -g -c test2.f90
$gfortran -o test1.o -g -c test1.f90
$gfortran -o test1 -g test1.o test2.o test3.o
test1.o: In function `test1':
/data/test1.f90:6: undefined reference to `__test2_MOD_testchar'
collect2: ld returned 1 exit status
make: *** [test1] Error 1
$ gfortran -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)
If I comment out the USE TEST3 line in test2.f90 then all is fine. The
test code also compiles and links without any problems with the intel
and IBM compilers. Given that everything is private in TEST3 then my
understanding is that it shouldn't matter if TEST2 uses it or not? Is
this a compiler bug or my misunderstanding of the use of COMMON blocks
inside PRIVATE modules?
Reported in
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/ca3ef24d9bf2afb8#
by Chris Bradley
--
Summary: [Regression, 4.4, 4.3] PUBLIC/PRIVATE Common blocks
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pault at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38657
More information about the Gcc-bugs
mailing list