https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122949
Bug ID: 122949
Summary: Error on invoking type-bound function on
associate-name
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: damian at archaeologic dot codes
Target Milestone: ---
The error below is somewhat similar to pr 121139, but the error below goes away
if the operator .grad. in the offending line is replaced by a direct invocation
of the corresponding type-bound procedure: s%grad().
$ cat reproducer.f90
module tensors_m
implicit none
type scalar_t
contains
generic :: operator(.grad.) => grad
procedure grad
end type
type vector_t
contains
procedure grid
end type
contains
module function grad(self) result(gradient)
class(scalar_t), intent(in) :: self
type(vector_t) gradient
gradient = vector_t()
end function
module function grid(self) result(x)
class(vector_t) self
real x
x = 0D0
end function
end module
use tensors_m
implicit none
type(scalar_t) :: s = scalar_t()
associate(grad_s => .grad. s)
associate(grad_s_grid => grad_s%grid())
end associate
end associate
end
$ gfortran reproducer.f90
reproducer.f90:34:29:
34 | associate(grad_s_grid => grad_s%grid())
| 1
Error: Invalid association target at (1)
reproducer.f90:36:5:
36 | end associate
| 1
Error: Expecting END PROGRAM statement at (1)
$ gfortran --version
GNU Fortran (GCC) 16.0.0 20251125 (experimental)