[Bug fortran/88632] New: [F08] function contained in module invisible to submodule unless declared public
joerg.stiller@tu-dresden.de
gcc-bugzilla@gcc.gnu.org
Fri Dec 28 22:10:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88632
Bug ID: 88632
Summary: [F08] function contained in module invisible to
submodule unless declared public
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: joerg.stiller@tu-dresden.de
Target Milestone: ---
A function is declared in the contains-part of a module to provide a common
functionality to different submodules. To make this function invisible to
exterior program units using this module, the function is kept private.
Nonetheless it should be visible to the submodules.
However, with `gfortran` the function remains invisible to the submodule(s),
which becomes apparent in the form of an `ld` error. This behavior can be fixed
by declaring the the function public.
To my understanding this is an error: The function should be visible to
submodules even when private.
Required information
1) Version of GCC
$ gfortran --version
GNU Fortran (MacPorts gcc8 8.2.0_3) 8.2.0
2) System type
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
3) Options given when GCC was configured/built
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
4) Complete command line that triggers the bug
gfortran -o main parent.f90 decendent.f90 main.f90
5) Output of `gfortran -v -save-temps -o main parent.f90 decendent.f90
main.f90`
Driving: gfortran-mp-8 -v -save-temps -o main parent.f90 decendent.f90 main.f90
-mmacosx-version-min=10.14.0 -asm_macosx_version_min=10.14 -l gfortran
-shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran-mp-8
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc8/gcc8/work/gcc-8.2.0/configure
--prefix=/opt/local --build=x86_64-apple-darwin18
--enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc8
--includedir=/opt/local/include/gcc8 --infodir=/opt/local/share/info
--mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-8
--with-local-prefix=/opt/local --with-system-zlib --disable-nls
--program-suffix=-mp-8 --with-gxx-include-dir=/opt/local/include/gcc8/c++/
--with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local
--with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto
--enable-libstdcxx-time --with-build-config=bootstrap-debug
--with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld
--with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket
--disable-tls --with-pkgversion='MacPorts gcc8 8.2.0_3'
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 8.2.0 (MacPorts gcc8 8.2.0_3)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc'
'-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/f951 parent.f90 -fPIC
-quiet -dumpbase parent.f90 -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase
parent -version -fintrinsic-modules-path
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/finclude -o parent.s
GNU Fortran (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/bin/as -v -arch x86_64 -force_cpusubtype_ALL -o parent.o parent.s
Apple Inc version cctools-921, GNU assembler version 1.38
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/f951 decendent.f90 -fPIC
-quiet -dumpbase decendent.f90 -mmacosx-version-min=10.14.0 -mtune=core2
-auxbase decendent -version -fintrinsic-modules-path
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/finclude -o decendent.s
GNU Fortran (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/bin/as -v -arch x86_64 -force_cpusubtype_ALL -o decendent.o
decendent.s
Apple Inc version cctools-921, GNU assembler version 1.38
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/f951 main.f90 -fPIC -quiet
-dumpbase main.f90 -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase main
-version -fintrinsic-modules-path
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/finclude -o main.s
GNU Fortran (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc8 8.2.0_3) version 8.2.0 (x86_64-apple-darwin18)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1,
MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/bin/as -v -arch x86_64 -force_cpusubtype_ALL -o main.o main.s
Apple Inc version cctools-921, GNU assembler version 1.38
Reading specs from
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/
LIBRARY_PATH=/opt/intel/compilers_and_libraries_2019.1.144/mac/tbb/lib/:/opt/intel/compilers_and_libraries_2019.1.144/mac/compiler/lib/:/opt/intel/compilers_and_libraries_2019.1.144/mac/mkl/lib/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'main'
'-mmacosx-version-min=10.14.0' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin18/8.2.0/collect2 -syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/
-dynamic -arch x86_64 -macosx_version_min 10.14.0 -weak_reference_mismatches
non-weak -o main -L/opt/intel/compilers_and_libraries_2019.1.144/mac/tbb/lib
-L/opt/intel/compilers_and_libraries_2019.1.144/mac/compiler/lib
-L/opt/intel/compilers_and_libraries_2019.1.144/mac/mkl/lib
-L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0
-L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/../../.. parent.o
decendent.o main.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc
-lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 8.2.0
/opt/local/bin/ld -syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/
-dynamic -arch x86_64 -macosx_version_min 10.14.0 -weak_reference_mismatches
non-weak -o main -L/opt/intel/compilers_and_libraries_2019.1.144/mac/tbb/lib
-L/opt/intel/compilers_and_libraries_2019.1.144/mac/compiler/lib
-L/opt/intel/compilers_and_libraries_2019.1.144/mac/mkl/lib
-L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0
-L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0/../../.. parent.o
decendent.o main.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc
-lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld PROJECT:ld64-409.12
BUILD 17:47:51 Sep 25 2018
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h
armv6m armv7k armv7m armv7em arm64e arm64_32
Library search paths:
/opt/intel/compilers_and_libraries_2019.1.144/mac/tbb/lib
/opt/intel/compilers_and_libraries_2019.1.144/mac/compiler/lib
/opt/intel/compilers_and_libraries_2019.1.144/mac/mkl/lib
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.2.0
/opt/local/lib/gcc8
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"___parent_MOD_my_number", referenced from:
___parent_MOD_my_method in decendent.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
5) Source files
5.1) parent.f90
---------------------------------------------------------------------
module parent
private
public :: my_type
type my_type
contains
procedure :: my_method
end type my_type
interface
module subroutine my_method(this)
class(my_type), intent(in) :: this
end subroutine my_method
end interface
contains
! common helper function to be used in differt submodules
integer function my_number()
my_number = 1
end function my_number
end module parent
---------------------------------------------------------------------
5.2) decendent.f90
---------------------------------------------------------------------
submodule(parent) decendent
contains
module subroutine my_method(this)
class(my_type), intent(in) :: this
print *, my_number()
end subroutine my_method
end submodule decendent
---------------------------------------------------------------------
5.3) main.f90
---------------------------------------------------------------------
program main
use parent
type(my_type) :: my
call my % my_method()
end program main
---------------------------------------------------------------------
More information about the Gcc-bugs
mailing list