gcc/fortran/ChangeLog:
2017-02-05 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/79230
* trans-array.c (structure_alloc_comps): Ignore pointer components when
freeing structures.
gcc/testsuite/ChangeLog:
2017-02-05 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/79230
* gfortran.dg/der_ptr_component_2.f90: New test.
From-SVN: r245191
+2017-02-05 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/79230
+ * trans-array.c (structure_alloc_comps): Ignore pointer components when
+ freeing structures.
+
2017-01-25 Maxim Ostapenko <m.ostapenko@samsung.com>
PR lto/79061
/* Shortcut to get the attributes of the component. */
if (c->ts.type == BT_CLASS)
- attr = &CLASS_DATA (c)->attr;
+ {
+ attr = &CLASS_DATA (c)->attr;
+ if (attr->class_pointer)
+ continue;
+ }
else
- attr = &c->attr;
+ {
+ attr = &c->attr;
+ if (attr->pointer)
+ continue;
+ }
if ((c->ts.type == BT_DERIVED && !c->attr.pointer)
|| (c->ts.type == BT_CLASS && !CLASS_DATA (c)->attr.class_pointer))
+2017-02-05 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/79230
+ * gfortran.dg/der_ptr_component_2.f90: New test.
+
2017-02-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc.target/sparc/20170205-1.c: New test.
--- /dev/null
+! { dg-do run }
+!
+! Freeing the width_data lead to double free. This testcase tests that
+! pr79230 is fixed now.
+
+program main_ut
+ implicit none
+
+ type :: data_t
+ character, allocatable :: c1
+ end type
+
+ type :: t1_t
+ character, allocatable :: c2
+ class(data_t), pointer :: width_data
+ end type
+
+ call evaluator
+
+contains
+
+ subroutine evaluator
+ type(data_t), target :: par_real
+ type(t1_t) :: field
+ field%width_data => par_real
+ end subroutine
+
+end
+
+