This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/40851] problem with deallocation of pointers



------- Comment #2 from burnus at gcc dot gnu dot org  2009-07-25 06:55 -------
CONFIRM. Affects all GCC with pointer intent (4.3/4.4/4.5). For

  subroutine set_ptr (ptr)
    type(string_container), pointer, intent(out) :: ptr

one shall not deallocate the pointer. The pointer intent is different from a
non-pointer intent:


set_ptr (struct string_container * & ptr)
{
  if (ptr != 0)
    {
      if (ptr->string.chars.data != 0B)
        {
          __builtin_free (ptr->string.chars.data);


Untested patch:

--- trans-decl.c        (Revision 150038)
+++ trans-decl.c        (Arbeitskopie)
@@ -2958,6 +3009,7 @@ init_intent_out_dt (gfc_symbol * proc_sy
   gfc_init_block (&fnblock);
   for (f = proc_sym->formal; f; f = f->next)
     if (f->sym && f->sym->attr.intent == INTENT_OUT
+         && !sym->attr.pointer
          && f->sym->ts.type == BT_DERIVED)
       {
        if (f->sym->ts.derived->attr.alloc_comp)
@@ -3708,6 +3760,7 @@ generate_local_decl (gfc_symbol * sym)
       if (!sym->attr.referenced
            && sym->ts.type == BT_DERIVED
            && sym->ts.derived->attr.alloc_comp
+           && !sym->attr.pointer
            && ((sym->attr.dummy && sym->attr.intent == INTENT_OUT)
                  ||
                (sym->attr.result && sym != sym->result)))


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-25 06:55:42
               date|                            |


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]