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

            Bug ID: 80757
           Summary: Internal compiler error when omitting upper subscript
                    of a character substring in a module subroutine
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: GF_bug_report at freemail dot hu
  Target Milestone: ---

Dear GNU Fortran Developers,

I found a bug in GNU Fortran.  The following code (module + main program)
causes internal compiler error.  Putting the problematic line from the 
module subroutine into the main program (as char_array(2:4)(3:)= 'FO') 
does not cause any compilation or runtime error.

Omitting the lower subscript like this:  ch_array(2:4)(:2)= 'FO'
compiles and runs without error.  

Omitting both subscripts like this:  ch_array(2:4)(:)= 'FO'
compiles and runs without error.


The error exists with -std=f95, f2003 and f2008 switches as well.
I use GNU Fortran 6.3.0 under Debian 9.0.
I have an older GNU Fortran also, v4.4.5. which produces the same error.


Thank you for your efforts in advance,
Aron



THE SOURCE CODE THAT CAUSES THE BUG:
module modu
  implicit none
contains

  subroutine sub(ch_array)
    character(len=*), intent(inout) :: ch_array(:)
!  Putting here ----v  `4' or `len(ch_array)', the code compiles.
    ch_array(2:4)(3:)= 'FO'
  endsubroutine sub
endmodule modu


program GF_compiler_error
  use modu
  implicit none
  character(len=4) :: char_array(6)
  integer :: j

  char_array= 'abcd'  ! vector operation
  write(*,'(i1,a)') (j,'_'//char_array(j)//'_', j=1,SIZE(char_array))
  write(*,*) ' '

  call sub(char_array)
  write(*,'(i1,a)') (j,'_'//char_array(j)//'_', j=1,SIZE(char_array))
endprogram GF_compiler_error



THE COMMAND LINE THAT TRIGGERS THE BUG:
gfortran -v -save-temps -std=f2008 -o out.bug ./character_array_bug.f90



THE COMPILER OUTPUT IS:
Driving: gfortran -v -save-temps -std=f2008 -o out.bug
./character_array_bug.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-16'
--with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-6 --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 --enable-default-pie
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--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 6.3.0 20170425 (Debian 6.3.0-16) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=f2008' '-o' 'out.bug'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/6/f951 ./character_array_bug.f90 -quiet
-dumpbase character_array_bug.f90 -mtune=generic -march=x86-64 -auxbase
character_array_bug -std=f2008 -version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-linux-gnu/6/finclude -o character_array_bug.s
GNU Fortran (Debian 6.3.0-16) version 6.3.0 20170425 (x86_64-linux-gnu)
        compiled by GNU C version 6.3.0 20170425, GMP version 6.1.2, MPFR
version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (Debian 6.3.0-16) version 6.3.0 20170425 (x86_64-linux-gnu)
        compiled by GNU C version 6.3.0 20170425, GMP version 6.1.2, MPFR
version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
./character_array_bug.f90:8:0:

     ch_array(2:4)(3:)= 'FO'

internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.

Reply via email to