Dear All, I ran into Ian Chivers in last week's BCS meeting, who told me that he had found a PDT bug. My response was to post it on Bugzilla, which he did.... promptly :-) So promptly, in fact, that I felt honour bound to respond in kind. Please find attached a patch to fix his bug and the extension to recursive allocatable instead of pointer components. The third testcase checks some tidying up in trans-array.c to stop valgrind complaining about jumps on uninitialized variables. It turns out that the earlier PDT tests that had PDT components in module declarations all made use of the default parameter expressions. Ian's bug exposed this and required the handiwork in module.c. This is straightforward and involves the hijacking of actual_arglist service functions as elsewhere in the initial PDT patch. Once recursive allocatable PDT components are added, the compiler tries to generate vtables and the associated procedures for the template types. This of course yields nonsense and so gfc_find_derived_vtab simply returns null. The rest of the patch is adequately explained apart from the seemingly trivial change in trans-decl.c. This problem was characterised by double freeing of a PDT type, as it goes out of scope, in the 'finally' block. Clearly somebody is using 'tmp' uninitialized but I am blowed if I can find the culprit. I have fixed it by setting it to NULL_TREE after the intended use. This is not very satisfactory since there is clearly a buglet lurking in the woods somewhere. My first thought was that, since this seems to be PDT related, it must be associated with the earlier PDT chunks. They all look to be clean, however. I have commented accordingly. Bootstraps and regtests on FC23/x86_64 - OK for trunk? Now to turn to Reinhold Bader's really nasty PDT bug.... Cheers Paul 2017-10-07 Paul Thomas PR fortran/82375 * class.c (gfc_find_derived_vtab): Return NULL for a passed pdt template to prevent bad procedures from being written. * decl.c (gfc_get_pdt_instance): Do not use the default initializer for pointer and allocatable pdt type components. If the component is allocatbale, set the 'alloc_comp' attribute of 'instance'. * module.c : Add a prototype for 'mio_actual_arglist'. Add a boolean argument 'pdt'. (mio_component): Call it for the parameter list of pdt type components with 'pdt' set to true. (mio_actual_arg): Add the boolean 'pdt' and, if it is set, call mio_integer for the 'spec_type'. (mio_actual_arglist): Add the boolean 'pdt' and use it in the call to mio_actual_arg. (mio_expr, mio_omp_udr_expr): Call mio_actual_arglist with 'pdt' set false. * resolve.c (get_pdt_spec_expr): Add the parameter name to the KIND parameter error. (get_pdt_constructor): Check that cons->expr is non-null. * trans-array.c (structure_alloc_comps): For deallocation of allocatable components, ensure that parameterized components are deallocated first. Likewise, when parameterized components are allocated, nullify allocatable components first. Do not recurse into pointer or allocatable pdt components while allocating or deallocating parameterized components. Test that parameterized arrays or strings are allocated before freeing them. (gfc_trans_pointer_assignment): Call the new function. Tidy up a minor whitespace issue. trans-decl.c (gfc_trans_deferred_vars): Set 'tmp' to NULL_TREE to prevent the expression from being used a second time. 2017-10-07 Paul Thomas PR fortran/82375 * gfortran.dg/pdt_13.f03 : New test. * gfortran.dg/pdt_14.f03 : New test. * gfortran.dg/pdt_15.f03 : New test. -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein