https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122433
Bug ID: 122433
Summary: [PDT] rejects valid conditional assignment of
recursive function invocation
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: ---
$ cat neuron_m.f90
module neuron_m
implicit none
type string_t
character(len=:), allocatable :: string_
end type
type neuron_t(k)
integer, kind :: k = kind(1.)
real(k) bias_
type(neuron_t(k)), allocatable :: next
end type
contains
recursive function from_json(neuron_lines, start) result(neuron)
type(string_t) neuron_lines(:)
integer start
type(neuron_t) neuron
character(len=:), allocatable :: line
line = neuron_lines(start+1)%string_
read(line(index(line, ":")+1:), fmt=*) neuron%bias_
line = adjustr(neuron_lines(start+3)%string_)
if (line(len(line):) == ",") neuron%next = from_json(neuron_lines, start+4)
end function
end module
$ gfortran -c neuron_m.f90
neuron_m.f90:23:34:
23 | if (line(len(line):) == ",") neuron%next = from_json(neuron_lines,
start+4)
| 1
Error: Syntax error in IF-clause after (1)
$ gfortran --version
GNU Fortran (GCC) 16.0.0 20251026 (experimental)
-----
On a related note, it appears that gfortran 16 requires the "recursive" keyword
above. Fortran 2018 removed the requirement for the keyword.