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

            Bug ID: 64947
           Summary: Internal compiler error: in gimplify_expr, at
                    gimplify.c:8425
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugs at stellardeath dot org

Created attachment 34676
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34676&action=edit
Fairly minimal testcase to trigger the bug.

The following (IMO valid) code produces an internal compiler error for gfortran
4.9.0 which is available on my openSUSE:

#> cat testcase.f90
module ice_gimplify_expr
  use, intrinsic :: iso_c_binding
  implicit none

  integer, parameter :: name_length = 40

  type :: node_t
    character(len=name_length) :: name
    contains
      procedure, pass :: get_child => node_get_child
  end type

  interface
    pure function strnlen(ptr, maxlen) result(size) bind(c, name="strnlen")
      use, intrinsic :: iso_c_binding
      type(c_ptr), intent(in), value :: ptr
      integer(kind=C_SIZE_T), intent(in), value :: maxlen
      integer(kind=C_SIZE_T) :: size
    end function
  end interface

  contains

  function node_get_child(self, name) result(child)
    class(node_t), intent(in) :: self
    character(len=*), intent(in) :: name
    type(node_t), pointer :: child
    child => NULL()
  end function

  function c_string(ptr) result(s)
    type(c_ptr), value, intent(in) :: ptr
    character(kind=C_CHAR, len=strnlen(ptr, int(name_length, kind=C_SIZE_T))),
pointer :: s
    call c_f_pointer(ptr, s)
  end function

  function node_from_strings(strings) result(node)
    type(node_t), pointer :: node
    type(c_ptr), intent(in), dimension(2) :: strings
    node => node%get_child(c_string(strings(1)))
  end function

end module
#> gfortran-4.9 --version
GNU Fortran (SUSE Linux) 4.9.0
Copyright (C) 2014 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

#> gfortran-4.9 -ffree-form -c testcase.f90
testcase.f90: In function ‘node_from_strings’:
testcase.f90:40:0: internal compiler error: in gimplify_expr, at
gimplify.c:8425
     node => node%get_child(c_string(strings(1)))
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
#>

Reply via email to