http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56491



             Bug #: 56491

           Summary: [OOP] Memory leak with vtab's type-bound-procedures

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: fortran

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org

                CC: ja...@gcc.gnu.org





gfc_find_derived_vtab (gfc_symbol *derived)

...

              if (gfc_add_component (vtype, "_copy", &c) == FAILURE)

                goto cleanup;

              c->attr.proc_pointer = 1;

              c->attr.access = ACCESS_PRIVATE;

              c->tb = XCNEW (gfc_typebound_proc);



The "c->tb" leaks memory; similarly for gfc_find_intrinsic_vtab.





Example:



class(*), allocatable :: A

allocate(integer :: a)

select type(a)

type is (integer)

  a= 5

  print *, a

end select

end





Looking at source.c, free_components does not handle TBP. Those are only freed

via gfc_free_namespace:

  free_tb_tree (ns->tb_sym_root);

  free_tb_tree (ns->tb_uop_root);

but vtab's tb do not end up in those symtrees.

Reply via email to