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

            Bug ID: 115348
           Summary: -fcheck=recursion issue with intent(out) derived type
                    argument without components with default value
           Product: gcc
           Version: 13.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: maxime.vandenbossche at kuleuven dot be
  Target Milestone: ---

Created attachment 58347
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58347&action=edit
Reproducer

With gfortran >= v13.3.0 (on x86-64), the attached example fails to compile
when runtime checks for recursion are included, e.g.:

~$ gfortran -fcheck=recursion test.f90
/usr/bin/ld: /tmp/ccG76pT1.o: warning: relocation against `is_recursive.0.2' in
read-only section `.text'
/usr/bin/ld: /tmp/ccG76pT1.o: in function `__mymodule_MOD_myroutine':
test.f90:(.text+0x37): undefined reference to `is_recursive.0.2'
/usr/bin/ld: test.f90:(.text+0x5f): undefined reference to `is_recursive.0.2'
/usr/bin/ld: test.f90:(.text+0xe5): undefined reference to `is_recursive.0.2'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

The issue dissapears when e.g. changing the intent of the "self" argument of
the "myroutine" procedure from "out" to "inout". The issue also dissapears when
giving a default value to the "mynumber" component of the "mytype" derived type
(e.g. "integer :: mynumber = 0") or when adding another component with a
default value (e.g. "integer :: mysecondnumber = 0").

But I would assume that also the unmodified example is valid code. If that
turns out not to be the case, then I'd still wish for a slightly more
descriptive error message :).

The example works fine with gfortran <= v13.2. Godbolt suggests the issue, if
confirmed, is also present in the nightly trunk build.
  • [Bug fortran/11534... maxime.vandenbossche at kuleuven dot be via Gcc-bugs

Reply via email to