https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70244

            Bug ID: 70244
           Summary: ICE spec_dimen_size() Bad dimension
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cfztol at hotmail dot com
  Target Milestone: ---

In the following program 3 out of 4 scenarios work fine. These are commented
away and marked with OK in the program section.

The last variation fails when the over-ridden function is supposed to return a
rank 2 array, and is marked with ICE.

module mymodule
    implicit none

    type, abstract :: base_t
    contains
        procedure(fun_i), deferred :: fun
    end type
    abstract interface
        function fun_i( self ) result( val )
            import
            class(base_t), intent(in) :: self
!            real, dimension(:), allocatable :: val   ! OK
            real, dimension(:,:), allocatable :: val ! ICE
        end function
    end interface

    type :: base_a
        class(base_t), allocatable :: obj
    end type

    type, extends(base_t) :: deriv_t
    contains
        procedure :: fun
    end type

contains

    function fun( self ) result( val )
        class(deriv_t), intent(in) :: self
!        real, dimension(:), allocatable :: val ! OK
        real, dimension(:,:), allocatable :: val ! ICE
    end function

end module

program bug
    use mymodule
    implicit none

! Causes ICE...
    type(base_a), dimension(1) :: e
    real, dimension(:,:), allocatable :: m
    allocate( deriv_t :: e(1)%obj )
    m = e(1)%obj%fun( )

! OK
!    type(base_a), dimension(1) :: e
!    real, dimension(:), allocatable :: m
!    allocate( deriv_t :: e(1)%obj )
!    m = e(1)%obj%fun( )

! OK
!    class(base_t), allocatable :: f
!    real, dimension(:,:), allocatable :: m
!    allocate( deriv_t :: f )
!    m = f%fun()

! OK
!    type(base_a) :: g
!    real, dimension(:,:), allocatable :: m
!    allocate( deriv_t :: g%obj )
!    m = g%obj%fun()
end program

Only the case where "fun" returns a rank 2 array in combination with going
through "e(1)%obj%..." causes an error. In this case I get:

gfortran -o bug -Wall -Wextra bug.f90
f951: internal compiler error: spec_dimen_size(): Bad dimension
Please submit a full bug report,

using this setup:

gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --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
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)

Reply via email to