This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/82367] New: ICE with deferred length string allocate on non-deferred length argument


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

            Bug ID: 82367
           Summary: ICE with deferred length string allocate on
                    non-deferred length argument
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: w6ws at earthlink dot net
  Target Milestone: ---

Incorrect code caused a ICE:

wws@w6ws-4:/tmp$ cat cls.f90
module cls_allocmod
  implicit none

contains

 subroutine cls_alloc (n, str)
    integer,  intent(in) :: n
    character(*), allocatable, intent(out) :: str
!  Note: Star ^ should have been a colon (:)

    allocate (character(n)::str)

  end subroutine

end module

program cls
  use cls_allocmod
  implicit none

  character(:), allocatable :: string

  call cls_alloc (42, string)
  print *, 'string len =', len(string)

end program
wws@w6ws-4:/tmp$ 

Gfortran 5.4 produces an ICE.  So do older versions (e.g., 4.8 on one of my
other machines.):

wws@w6ws-4:/tmp$ gfortran --version
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

wws@w6ws-4:/tmp$ gfortran cls.f90
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
wws@w6ws-4:/tmp$ 

The trunk as of a couple of days ago also produces an ICE - this time with a
compiler traceback:

wws@w6ws-4:/tmp$ /usr/local/gcc-trunk/bin/gfortran --version
GNU Fortran (GCC) 8.0.0 20170927 (experimental)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

wws@w6ws-4:/tmp$ /usr/local/gcc-trunk/bin/gfortran cls.f90
f951: internal compiler error: Segmentation fault
0xc906cf crash_signal
        ../../gcc-trunk/gcc/toplev.c:326
0x727af8 gfc_dep_compare_expr(gfc_expr*, gfc_expr*)
        ../../gcc-trunk/gcc/fortran/dependency.c:321
0x6fe687 resolve_allocate_expr
        ../../gcc-trunk/gcc/fortran/resolve.c:7391
0x6fe687 resolve_allocate_deallocate
        ../../gcc-trunk/gcc/fortran/resolve.c:7782
0x70067a gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:11212
0x701c02 resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.c:16236
0x701b07 resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.c:16221
0x701d06 gfc_resolve(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:16271
0x6eb54c gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:6217
0x7313af gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:204
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
wws@w6ws-4:/tmp$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]