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

            Bug ID: 61627
           Summary: specification expression ICE with version 4.7.1 and
                    4.8.2, incorrect output with 4.4.7 and 4.9.0
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harper at msor dot vuw.ac.nz

This 4-line Fortran program

  character(len('xyz')):: head1(2) = (/'a','b'/)
  character(3)         :: head2(2) = (/'x','y'/)
  write(*,*) head1,head2
  end program

gives an ICE with gfortran 4.7.1 or 4.8.2. It compiles and runs with gfortran
4.4.7 or 4.9.0 but gives what I believe to be wrong output: those compiler
versions treated head1 as being declared with length 1. G95 version 0.94, ifort
version 14.0.0 and Sun Fortran 8.6 all get it right, declaring head1 with
length 3.

With version 4.8.2 (same ICE message  with 4.7.1 except for varasm.c:4821):

cayley[~/Jfh] % gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.8-20131219/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-cloog-version-check --enable-lto
--enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu
--disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.2 20131219 (prerelease) (GCC) 
cayley[~/Jfh] % gfortran gfbug.f90
gfbug.f90:4:0: internal compiler error: in output_constructor_regular_field, at
varasm.c:4813
 end program
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
cayley[~/Jfh] % 

With 4.9.0 (same result with 4.4.7):

cayley[~/Jfh] % gf gfbug.f90
cayley[~/Jfh] % ./a.out
 abx  y  
cayley[~/Jfh] % 

It seems that head1 was declared with length 1 instead of len('xyz') which is
3;
I believe the 4.9.0 output should have been
   a  b  x  y 
which is what g95, Intel and Sun all gave.

Reply via email to