https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122556
--- Comment #4 from kargls at comcast dot net ---
So, it appears that in tearing down a symbol that corresponds
to a PDT, the routine symbol.cc:free_components() is trying
to free initializers. If I use this patch,
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 8211d926cf6..15bcdf93cdf 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -2677,7 +2677,10 @@ free_components (gfc_component *p)
q = p->next;
gfc_free_array_spec (p->as);
- gfc_free_expr (p->initializer);
+ if (p->attr.pointer)
+ p->initializer = NULL;
+ else
+ gfc_free_expr (p->initializer);
if (p->kind_expr)
gfc_free_expr (p->kind_expr);
if (p->param_list)
the simplified testcase
module m11
real, target :: trgt
type :: t(i)
integer, len :: i
real, pointer :: pntr => trgt
end type
contains
subroutine s1(x)
type(t(*)), intent(in) :: x
end subroutine
end module
yields
% gfcx -c ~/tmp/a.f90
/usr/home/sgk/tmp/a.f90:5:32:
5 | real, pointer :: pntr => trgt
| 1
Error: Parameter 'trgt' at (1) has not been declared or is a variable, which
does not reduce to a constant expression
I think that there is a resolution problem in that the error message
makes no sense to me. 'trgt' has certainly been declared, and this
a pointer initialization not a default initialization involving
a constant expression.
Clearly, a problen to be address during resolution. Changing the testcase
to
module m11
real(4), target :: trgt
type :: t(i)
integer, kind :: i = 4
real(i), pointer :: pntr => trgt
end type
contains
subroutine s1(x)
type(t(4)), intent(in) :: x
end subroutine
end module
yields
% gfcx -c a.f90
a.f90:9:13:
9 | type(t(4)), intent(in) :: x
| 1
Error: Different types in pointer assignment at (1); attempted assignment of
UNKNOWN to REAL(4)
a.f90:5:35:
5 | real(i), pointer :: pntr => trgt
| 1
Error: Different types in pointer assignment at (1); attempted assignment of
REAL(4) to REAL(0)