[Bug fortran/92050] New: internal compiler error: in gfc_conv_procedure_call

2019-10-10 Thread rp83 at gmx dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92050

Bug ID: 92050
   Summary: internal compiler error: in gfc_conv_procedure_call
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rp83 at gmx dot com
  Target Milestone: ---

The module in the minimal working example below triggers an internal compiler
error when compiled with gfortran -fcheck=all.

- System: Ubuntu 18.04.3 LTS, 4.15.0-65-generic x86_64
- Command line that triggers the bug: gfortran -fcheck=all -c buggy.f95
- Regression: the bug is triggered when the code is compiled with gfortran
versions 9, 8, 7, but not with versions 5 and 6.

A few observations:
- Calling the function fun_par() directly rather than the binding "fun" does
not trigger the bug: 
  write(*,*) fun_par(this%m(1)%p, x)
- Defining "p" in "comp" using "type(par)" instead of "class(par)" does not
trigger the bug.
- Same bug when "p" is specified to be a pointer instead of an allocatable
vector.
- When the dimension of the result y in fun_par() is a scalar (y instead of
y(size(x))), the bug is not triggered.


MINIMAL WORKING EXAMPLE: buggy.f95

module buggy
  implicit none

  type :: par
  contains
procedure, public :: fun => fun_par
  end type par

  type comp
class(par), allocatable :: p
  end type comp

  type foo
type(comp), allocatable :: m(:)
  end type foo

contains

  function fun_par(this)
class(par) :: this
integer:: fun_par(1)
fun_par = 0
  end function fun_par

  subroutine update_foo(this)
class(foo) :: this
write(*,*) this%m(1)%p%fun()
  end subroutine update_foo

end module buggy


COMPILER OUTPUTS

The code was tested using gfortran versions 9, 8, 7, 6, and 5:

GNU Fortran (Ubuntu 9.2.1-8ubuntu1~18.04.york0) 9.2.1 20190909
GNU Fortran (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
GNU Fortran (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
GNU Fortran (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
GNU Fortran (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010

using gfortran 5 and 6: no errors.

using gfortran 9, 8, and 7:

$ gfortran-9 -fcheck=all -c buggy.f95 
buggy.f95:27:0:

   27 | write(*,*) this%m(1)%p%fun()
  | 
internal compiler error: in gfc_conv_procedure_call, at
fortran/trans-expr.c:6785
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

$ gfortran-8 -fcheck=all -c buggy.f95 
buggy.f95:27:0:

 write(*,*) this%m(1)%p%fun()

internal compiler error: in gfc_conv_procedure_call, at
fortran/trans-expr.c:6410
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

$ gfortran-7 -fcheck=all -c buggy.f95 
buggy.f95:27:0:

 write(*,*) this%m(1)%p%fun()

internal compiler error: in gfc_conv_procedure_call, at
fortran/trans-expr.c:6290
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

[Bug fortran/92065] New: internal compiler error: in expand_expr_real_1

2019-10-11 Thread rp83 at gmx dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92065

Bug ID: 92065
   Summary: internal compiler error: in expand_expr_real_1
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rp83 at gmx dot com
  Target Milestone: ---

The following minimal working example triggers an internal compiler error when
compiled with gfortran -c buggy.f95.

Compiler error appears with gfortran versions 9, 8, 7, 6, but not version 5.
See outputs below.

Tests run on Ubuntu 18.04.3 LTS, 4.15.0-65-generic x86_64.

=
buggy.f95:

module buggy
  implicit none

  type :: bar
integer :: x
  end type bar

  type :: foo
integer :: n
  contains
procedure :: fun1
procedure :: fun2
  end type foo

contains

  subroutine fun1(this, a)
implicit none
class(foo) :: this
class(bar), intent(in) :: a(this%n)
  end subroutine fun1

  integer function fun2(this, a)
implicit none
class(foo) :: this
class(bar), intent(in) :: a(this%n)
fun2 = a(1)%x
  end function fun2

end module buggy

=
COMPILER OUTPUTS

with GNU Fortran (Ubuntu 9.2.1-8ubuntu1~18.04.york0) 9.2.1 20190909:

$ gfortran-9 -c buggy.f95
during RTL pass: expand
buggy.f95:23:0:

   23 |   integer function fun2(this, a)
  | 
internal compiler error: in expand_expr_real_1, at expr.c:10012
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

with GNU Fortran (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0:

$ gfortran-8 -c buggy.f95
during RTL pass: expand
buggy.f95:23:0:

   integer function fun2(this, a)

internal compiler error: in expand_expr_real_1, at expr.c:10047
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

with GNU Fortran (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0:

$ gfortran-7 -c buggy.f95
buggy.f95:23:0:

   integer function fun2(this, a)

internal compiler error: in expand_expr_real_1, at expr.c:9912
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

with GNU Fortran (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026:

$ gfortran-6 -c buggy.f95
buggy.f95:23:0:

   integer function fun2(this, a)

internal compiler error: in expand_expr_real_1, at expr.c:9702
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

with GNU Fortran (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010: no compiler error.