https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125578
Bug ID: 125578
Summary: [PDT] Default initialization failures with polymorphic
PDT
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: neil.n.carlson at gmail dot com
Target Milestone: ---
Here are a couple of default initialization failures involving polymorphic PDT.
I don't see any of these listed in the remaining unresolved reports listed in
the PDT meta bug.
This segfaults when run. If the unused internal procedure is removed it runs
without error:
program pdt_default_initialization
type :: owner(k)
integer, kind :: k = kind(0)
integer, allocatable :: a(:)
end type
type(owner(kind(0))) :: x
contains
subroutine reset(this)
class(owner(kind(0))), intent(out) :: this
end subroutine
end program
In this example the reset subroutine should set the variable to its default
initialization state; it doesn't.
program gcc_default_initialization
type :: owner(k)
integer, kind :: k = kind(0)
integer :: n = 42
end type
type(owner(kind(0))) :: x
print *, 'initial x%n = ', x%n
call reset(x)
print *, 'after reset x%n = ', x%n
if (x%n /= 42) error stop 'PDT polymorphic intent(out) reset lost scalar
default initialization'
contains
subroutine reset(this)
class(owner(kind(0))), intent(out) :: this
end subroutine
end program
Output:
initial x%n = 42
after reset x%n = 0
ERROR STOP PDT polymorphic intent(out) reset lost scalar default initialization