[Bug fortran/85357] ICE on invalid code with equal procedure names
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357 --- Comment #10 from c...@mnet-mail.de --- Thanks for the fix, and a Happy New Year to you guys!
[Bug fortran/88710] New: [F08] Sourced allocation of array fails, yielding wrong bounds and result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88710 Bug ID: 88710 Summary: [F08] Sourced allocation of array fails, yielding wrong bounds and result Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: c...@mnet-mail.de Target Milestone: --- The following code shows that sourced allocation of an allocatable array with gfortran 8.1.0 leads to wrong lower and upper bounds that do not correspond to those of the source expression. Moreover, the initialized array therefore does not yield the correct result expected from the value of the source expression. $ cat test_alloc.F90 program test_alloc implicit none integer(4) :: i, j, k real(8), dimension(:,:,:), allocatable :: a, b, c, t allocate( a(-1:2,-1:1,1:1) ) allocate( b(-1:2,-1:1,1:1) ) allocate( c(-1:2,-1:1,1:1) ) a = 1.d0 b = 2.d0 c = 0.d0 allocate(t, source = (a + (c - b)) ) write(*,'(a,6(i5,1x))') 'lbound/ubound(a): ', lbound(a), ubound(a) write(*,'(a,6(i5,1x))') 'lbound/ubound(b): ', lbound(b), ubound(b) write(*,'(a,6(i5,1x))') 'lbound/ubound(c): ', lbound(c), ubound(c) write(*,'(a,6(i5,1x))') 'lbound/ubound(t): ', lbound(t), ubound(t) write(*,*) 'a, b, c, t: ' do k = lbound(a,3), ubound(a,3) do j = lbound(a,2), ubound(a,2) do i = lbound(a,1), ubound(a,1) write(*,'(1p,4(e23.16,1x))') & & a(i,j,k), b(i,j,k), c(i,j,k), t(i,j,k) end do end do end do end program test_alloc Running this code with gfortran 8.1.0 gives the following output. $ gfortran-8 test_alloc.F90 -o test.gfort; ./test.gfort lbound/ubound(a):-1-1 1 2 1 1 lbound/ubound(b):-1-1 1 2 1 1 lbound/ubound(c):-1-1 1 2 1 1 lbound/ubound(t): 0 0 0 3 2 0 a, b, c, t: 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 0.E+00 1.E+00 2.E+00 0.E+00 1.6304166312761136-322 1.E+00 2.E+00 0.E+00 1.0023829485142537E-95 1.E+00 2.E+00 0.E+00 3.4119363283543871-315 1.E+00 2.E+00 0.E+00 0.E+00 1.E+00 2.E+00 0.E+00 2.0716172530123468-320 1.E+00 2.E+00 0.E+00 9.6317959318370178-317 Both flang 6.0 and pgfortran 18.4-0 yield the following (correct) output (notice the different bounds for t, and its values printed in the last column): $ flang test_alloc.F90 -o test.flang; ./test.flang lbound/ubound(a):-1-1 1 2 1 1 lbound/ubound(b):-1-1 1 2 1 1 lbound/ubound(c):-1-1 1 2 1 1 lbound/ubound(t):-1-1 1 2 1 1 a, b, c, t: 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 1.E+00 2.E+00 0.E+00 -1.E+00 Gfortran version used is: $ gfortran-8 -v Using built-in specs. COLLECT_GCC=gfortran-8 COLLECT_LTO_
[Bug fortran/88710] [F08] Sourced allocation of array fails, yielding wrong bounds and result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88710 --- Comment #2 from c...@mnet-mail.de --- Yes, the said block accesses 't' outside its bounds (because the returned bounds are wrong). Thanks for mentioning this. For what it's worth, I have compiled the code also with '-Wall' and '-Warray-bounds' but both these options didn't give any warning.
[Bug fortran/88710] [F08] Sourced allocation of array fails, yielding wrong bounds and result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88710 --- Comment #4 from c...@mnet-mail.de --- Thanks, this caught the bounds violation with the following output: lbound/ubound(a):-1-1 1 2 1 1 lbound/ubound(b):-1-1 1 2 1 1 lbound/ubound(c):-1-1 1 2 1 1 lbound/ubound(t): 0 0 0 3 2 0 a, b, c, t: At line 28 of file test_alloc.F90 Fortran runtime error: Index '1' of dimension 3 of array 't' above upper bound of 0 Error termination. Backtrace: #0 0x2b3018cf341a #1 0x2b3018cf3f75 #2 0x2b3018cf4347 #3 0x403e97 #4 0x40400f #5 0x2b301917182f #6 0x4008d8 #7 0x
[Bug fortran/85357] New: Regression: gfortran versions 7.2.0/8.0.1 reject F03 procedure overriding
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357 Bug ID: 85357 Summary: Regression: gfortran versions 7.2.0/8.0.1 reject F03 procedure overriding Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: c...@mnet-mail.de Target Milestone: --- Created attachment 43913 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43913&action=edit gfortran 7.2.0/8.0.1 error messages for above procedure overriding code The following valid Fortran 2003 (sample) code, that uses subroutine overriding, fails to compile with both gfortran 7.2.0 and 8.0.1 versions, but did compile with gfortran 7.1. It also compiles fine with PGI/Nvidia's pgfortran (17.4) and (LLVM-)flang (6.0). module base implicit none type, abstract :: base_type contains procedure :: summation end type base_type contains subroutine summation(self,i,j) class(base_type) :: self integer(4), intent(in) :: i integer(4), intent(out) :: j j = i + 1 end subroutine summation end module base module extended use base implicit none type, extends(base_type) :: extended_type contains procedure :: summation end type extended_type contains subroutine summation(self,i,j) class(extended_type) :: self integer(4), intent(in) :: i integer(4), intent(out) :: j j = i + 2 end subroutine summation end module extended Compiler error messages (identical for both gfortran versions) are attached as a separate file below. gfortran Version 7.2.0 used is: Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.2.0-1ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04) gfortran Version 8.0.1 used is: Using built-in specs. COLLECT_GCC=/home/kk/Gcc-8/bin/gfortran8 COLLECT_LTO_WRAPPER=/home/kk/Gcc-8/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-checking --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --enable-shared --enable-threads=posix --program-suffix=8 --with-gmp=/usr/local/lib --with-mpc=/usr/lib --with-mpfr=/usr/lib --without-included-gettext --with-system-zlib --with-tune=generic --prefix=/home/kk/GCC-8 Thread model: posix gcc version 8.0.1 20180409 (experimental) (GCC)
[Bug fortran/85357] gfortran versions 7.2.0/8.0.1 reject F03 procedure overriding
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357 c...@mnet-mail.de changed: What|Removed |Added Summary|Regression: gfortran|gfortran versions |versions 7.2.0/8.0.1 reject |7.2.0/8.0.1 reject F03 |F03 procedure overriding|procedure overriding --- Comment #1 from c...@mnet-mail.de --- Can't actually vouch for gfortran 7.1 being able to compile this, as I no longer have access to that gfortran version, so I changed the title (might still be a regression, though). Also, when replacing the line: use base by use base, only: base_type the code compiles with both gfortran 7.2.0 and 8.0.1.
[Bug fortran/85395] New: [7/8] F03 private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 Bug ID: 85395 Summary: [7/8] F03 private clause contained in derived type acquires spurious scope Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: c...@mnet-mail.de Target Milestone: --- The following valid Fortran2003 sample code fails to compile with gfortran 7.2.0/8.0.1, apparently because the private clause contained in derived type "base2" obtains a spurious scope and affects the declaration of variables in the (subsequently defined) derived type "options": $ cat scope.f90 module defs implicit none private public :: base2, options abstract interface subroutine proc( res,a ) real(8), dimension(:,:), intent(out) :: res real(8), dimension(:,:), intent(in) :: a end subroutine proc end interface type, abstract :: base1 contains end type base1 type, abstract :: base2 contains ! This private clause acquires spurious scope private end type base2 type, abstract, extends(base1) :: options procedure(proc), pointer, nopass :: ptr1 procedure(proc), pointer, nopass :: ptr2 contains end type options end module defs module setup use defs, only: options implicit none private public :: settings type, extends(options) :: settings contains procedure :: init end type settings contains subroutine init(self) class(settings) :: self ! initialize procedure pointers self%ptr1 => null() self%ptr2 => null() end subroutine init end module setup Trying to compile this gives: $ gfortran8 -c scope.f90 scope.f90:53:15: self%ptr1 => null() 1 Error: Component ‘ptr1’ at (1) is a PRIVATE component of ‘options’ scope.f90:54:15: self%ptr2 => null() 1 Error: Component ‘ptr2’ at (1) is a PRIVATE component of ‘options’ Presently the only ways to get the above code to compile with gfortran are by i) deleting the aforementioned private clause, or ii) explicitly declaring the procedure pointers in type options as "public". The original code compiles fine with pgfortran 17.4 and flang 6.0. Gfortran version 8.0.1 used is: Using built-in specs. COLLECT_GCC=/home/kk/Gcc-8/bin/gfortran8 COLLECT_LTO_WRAPPER=/home/kk/Gcc-8/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-checking --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --enable-shared --enable-threads=posix --program-suffix=8 --with-gmp=/usr/local/lib --with-mpc=/usr/lib --with-mpfr=/usr/lib --without-included-gettext --with-system-zlib --with-tune=generic --prefix=/home/kk/GCC-8 Thread model: posix gcc version 8.0.1 20180409 (experimental) (GCC)
[Bug fortran/86242] New: [F03] ICE for derived type with allocatable class component
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86242 Bug ID: 86242 Summary: [F03] ICE for derived type with allocatable class component Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: c...@mnet-mail.de Target Milestone: --- The following Fortran 2003 code (which compiles with flang 6.0, pgfortran 17.10, and ifort 19.0.0.070 Beta) generates an internal compiler error (ICE) with gfortran 8.0.1: $ cat test.F90 module test implicit none private public :: tester type :: wrapper integer(4) :: n end type wrapper type :: output real(8) :: dummy end type output type :: tester class(wrapper), allocatable :: wrap procedure(proc1), pointer :: ptr => null() end type tester abstract interface function proc1(self) result(uc) import :: tester, output class(tester), intent(in) :: self class(output), allocatable :: uc end function proc1 end interface end module test $ gfortran-8 -c test.F90 test.F90:29:0: end module test internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See for instructions. Gfortran version output is: $ gfortran-8 -v Using built-in specs. COLLECT_GCC=gfortran-8 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8-20180424-0ubuntu1~16.04.1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.0.1 20180424 (experimental) [trunk revision 259590] (Ubuntu 8-20180424-0ubuntu1~16.04.1)
[Bug fortran/86242] [6/7/8/9 Regression] [OOP] ICE for derived type with allocatable component and proc-ptr component
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86242 --- Comment #11 from c...@mnet-mail.de --- Thanks for the fix! On 07/03/2018 12:48 PM, pault at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86242 > > Paul Thomas changed: > > What|Removed |Added > > Status|NEW |RESOLVED > Resolution|--- |FIXED > > --- Comment #10 from Paul Thomas --- > Fixed on 6- through 9-branches. > > The I used the wrong logfile for the commits to 8- and 9-branches; it went to > PR45305 instead. > > Thanks for the report. > > Paul >
[Bug fortran/86576] New: [F03][OOP] Sourced allocation of object array fails with SEGFAULT
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86576 Bug ID: 86576 Summary: [F03][OOP] Sourced allocation of object array fails with SEGFAULT Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: c...@mnet-mail.de Target Milestone: --- The following Fortran 2003 test code, that makes extensive use of sourced allocation, should build and allocate an array of objects, and then simply terminate gracefully. It indeed does so when compiled with flang 6.0, pgfortran 18.4, and ifort 19 Beta. However, it leads to a segmentation fault when compiled with gfortran, as follows: $ cat test.F90 module build implicit none private public :: Builder, Otype type :: Ftype procedure(proc), pointer :: ptr => null() end type Ftype abstract interface subroutine proc( self,arr1,arr2 ) import :: Ftype class(Ftype), intent(in) :: self real(8), dimension(:,:), intent(in) :: arr1 real(8), dimension(:,:), intent(out) :: arr2 end subroutine proc end interface type :: Gtype type(Ftype) :: ff end type Gtype type :: Otype class(Gtype), allocatable :: og end type Otype type :: Builder class(Otype), dimension(:), allocatable :: outarr contains procedure :: init procedure :: get_result end type Builder interface Builder procedure constructor end interface Builder contains function constructor( nd ) ! ! Constructor for Builder objects. ! type(Builder) :: constructor integer(4), intent(in) :: nd call constructor%init( nd ) end function constructor subroutine init( self,nd ) ! ! Initializes the Builder. Constructs an array of output objects. ! class(Builder), intent(inout) :: self integer(4), intent(in) :: nd integer(4) :: i class(Ftype), allocatable :: ff ! allocate space for output array allocate( self%outarr(nd) ) ! fill it with some values allocate( ff, source = Ftype() ) do i = 1, nd allocate( self%outarr(i)%og, source = Gtype( ff ) ) end do end subroutine init function get_result( self ) result( outarr ) ! ! Returns a copy of the array of output objects. ! class(Builder), intent(in) :: self class(Otype), dimension(:), allocatable :: outarr allocate( outarr, source = self%outarr ) end function get_result end module build program test use build, only: Builder, Otype implicit none integer(4), parameter :: nd = 2 class(Builder), allocatable :: bld class(Otype), dimension(:), allocatable :: outarr ! get a builder object allocate( bld, source = Builder(nd) ) ! return a copy of the array of output objects allocate( outarr, source = bld%get_result() ) end program test $ gfortran-8 test.F90 -o test; ./test Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x2b08a615441a #1 0x2b08a6153603 #2 0x2b08a65e74af #3 0x40224f #4 0x402438 #5 0x2b08a65d282f #6 0x400768 #7 0x Segmentation fault Gfortran version output is: $ gfortran-8 -v Using built-in specs. COLLECT_GCC=gfortran-8 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.1.0-5ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.1.0 (Ubuntu 8.1.0-5ubuntu1~16.04)
[Bug fortran/85357] gfortran versions 7.2.0/8.0.1 reject F03 procedure overriding
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357 --- Comment #5 from c...@mnet-mail.de --- It would be rather surprising if the Fortran standard viewed this as being invalid code (the procedure in question is bound to a dervied type, hence should be overridable). Better to consult the standard to be sure (don't have a copy at hand, unfortunately). On 08/29/2018 09:47 PM, janus at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357 > > janus at gcc dot gnu.org changed: > > What|Removed |Added > > CC||janus at gcc dot gnu.org > > --- Comment #4 from janus at gcc dot gnu.org --- > I would argue that the code is actually invalid. A current trunk build shows: > > 23 |use base > | 2 > > 34 |subroutine summation(self,i,j) > | 1 > Error: Procedure ‘summation’ at (1) is already defined at (2) > > That's also what I get with all earlier versions I tried, and I think the > error > is correct. > > The only bug I can see is the ICE that occurs with trunk (after the original > error message and a couple of follow-up errors): > > f951: internal compiler error: Segmentation fault > 0xc5ac8f crash_signal > /home/jweil/github/gcc/trunk/gcc/toplev.c:325 > 0x6a75b4 free_sym_tree > /home/jweil/github/gcc/trunk/gcc/fortran/symbol.c:3892 > 0x6a75bc free_sym_tree > /home/jweil/github/gcc/trunk/gcc/fortran/symbol.c:3892 > 0x6a75bc free_sym_tree > /home/jweil/github/gcc/trunk/gcc/fortran/symbol.c:3892 > 0x6a75bc free_sym_tree > /home/jweil/github/gcc/trunk/gcc/fortran/symbol.c:3892 > 0x6a75bc free_sym_tree > /home/jweil/github/gcc/trunk/gcc/fortran/symbol.c:3892 > > Looks like an infinite recursion in 'free_sym_tree'. >