public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40851]  New: problem with deallocation of pointers
@ 2009-07-24 20:03 juergen dot reuter at desy dot de
  2009-07-24 20:05 ` [Bug fortran/40851] " juergen dot reuter at desy dot de
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: juergen dot reuter at desy dot de @ 2009-07-24 20:03 UTC (permalink / raw)
  To: gcc-bugs

gfortran seems to deallocate a pointer which was not allocated or need not be
allocated. The program below compiles, but when executed returns the following
error message:
a.out(8814) malloc: *** error for object 0x1fa2: Non-aligned pointer being
freed
*** set a breakpoint in malloc_error_break to debug
Bus error
(Happens for Linux x86 and x86-64 as well as MAC OS X)
The code is:
program main

  type :: string
     character,dimension(:),allocatable :: chars
  end type string

  type :: string_container
     type(string) :: string
  end type string_container

  type(string_container), pointer :: ptr

  call set_ptr (ptr)

contains

  subroutine set_ptr (ptr)
    type(string_container), pointer, intent(out) :: ptr
    ptr => null ()
  end subroutine set_ptr

end program main


-- 
           Summary: problem with deallocation of pointers
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: juergen dot reuter at desy dot de
 GCC build triplet: 4.5.0 v149701
  GCC host triplet: Linux x86. x86-64 and MAC OS X
GCC target triplet: gfortran


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
@ 2009-07-24 20:05 ` juergen dot reuter at desy dot de
  2009-07-25  6:56 ` burnus at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juergen dot reuter at desy dot de @ 2009-07-24 20:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from juergen dot reuter at desy dot de  2009-07-24 20:04 -------
Created an attachment (id=18249)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18249&action=view)
main program for pointer output


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
  2009-07-24 20:05 ` [Bug fortran/40851] " juergen dot reuter at desy dot de
@ 2009-07-25  6:56 ` burnus at gcc dot gnu dot org
  2009-07-25 19:14 ` burnus at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-25  6:56 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
  2009-07-24 20:05 ` [Bug fortran/40851] " juergen dot reuter at desy dot de
  2009-07-25  6:56 ` burnus at gcc dot gnu dot org
@ 2009-07-25 19:14 ` burnus at gcc dot gnu dot org
  2009-07-27  9:32 ` burnus at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-25 19:14 UTC (permalink / raw)
  To: gcc-bugs



-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-07-25 06:55:42         |2009-07-25 19:14:43
               date|                            |


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (2 preceding siblings ...)
  2009-07-25 19:14 ` burnus at gcc dot gnu dot org
@ 2009-07-27  9:32 ` burnus at gcc dot gnu dot org
  2009-07-27  9:33 ` [Bug fortran/40851] [4.3/4.4] " burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-27  9:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2009-07-27 09:32 -------
Subject: Bug 40851

Author: burnus
Date: Mon Jul 27 09:32:20 2009
New Revision: 150108

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150108
Log:
2009-07-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * resolve.c (resolve_symbol): Do not initialize pointer
        * derived-types.
        * trans-decl.c (init_intent_out_dt): Ditto.
        (generate_local_decl): No need to set attr.referenced for DT pointers.

2009-07-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * gfortran.dg/derived_init_3.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/derived_init_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (3 preceding siblings ...)
  2009-07-27  9:32 ` burnus at gcc dot gnu dot org
@ 2009-07-27  9:33 ` burnus at gcc dot gnu dot org
  2009-07-29  9:35 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-27  9:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2009-07-27 09:33 -------
Thanks for the report. FIXED on the trunk (4.5); I will soon backport it to
4.4/4.3.

(Workaround: Do not use INTENT for pointers [which is a Fortran 2003 feature].)


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|4.5.0 v149701               |
   GCC host triplet|Linux x86. x86-64 and MAC OS|
                   |X                           |
 GCC target triplet|gfortran                    |
            Summary|problem with deallocation of|[4.3/4.4] problem with
                   |pointers                    |deallocation of pointers


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (4 preceding siblings ...)
  2009-07-27  9:33 ` [Bug fortran/40851] [4.3/4.4] " burnus at gcc dot gnu dot org
@ 2009-07-29  9:35 ` burnus at gcc dot gnu dot org
  2009-08-16 20:29 ` [Bug fortran/40851] [4.3/4.4/4.5] " burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-29  9:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2009-07-29 09:35 -------
Subject: Bug 40851

Author: burnus
Date: Wed Jul 29 09:35:15 2009
New Revision: 150203

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150203
Log:
2009-07-29  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * resolve.c (resolve_symbol): Do not initialize pointer
        * derived-types.
        * trans-decl.c (init_intent_out_dt): Ditto.
        (generate_local_decl): No need to set attr.referenced for DT pointers.

2009-07-29  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * gfortran.dg/derived_init_3.f90: New test.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/derived_init_3.f90
Modified:
    branches/gcc-4_4-branch/gcc/fortran/ChangeLog
    branches/gcc-4_4-branch/gcc/fortran/resolve.c
    branches/gcc-4_4-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (5 preceding siblings ...)
  2009-07-29  9:35 ` burnus at gcc dot gnu dot org
@ 2009-08-16 20:29 ` burnus at gcc dot gnu dot org
  2009-08-16 20:29 ` [Bug fortran/40851] [4.3] " burnus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-08-16 20:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from burnus at gcc dot gnu dot org  2009-08-16 20:29 -------
FIXED on the 4.3 branch -> Close.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
            Summary|[4.3] problem with          |[4.3/4.4/4.5] problem with
                   |deallocation of pointers    |deallocation of pointers


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (6 preceding siblings ...)
  2009-08-16 20:29 ` [Bug fortran/40851] [4.3/4.4/4.5] " burnus at gcc dot gnu dot org
@ 2009-08-16 20:29 ` burnus at gcc dot gnu dot org
  2009-08-16 20:52 ` [Bug fortran/40851] [4.3/4.4/4.5] " steven at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-08-16 20:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2009-08-16 20:29 -------
Subject: Bug 40851

Author: burnus
Date: Sun Aug 16 20:29:02 2009
New Revision: 150813

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150813
Log:
2009-08-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * resolve.c (resolve_symbol): Do not initialize pointer
        * derived-types.
        * trans-decl.c (init_intent_out_dt): Ditto.
        (generate_local_decl): No need to set attr.referenced for DT pointers.

2009-08-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * gfortran.dg/derived_init_3.f90: New test.


Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/resolve.c
    branches/gcc-4_3-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (7 preceding siblings ...)
  2009-08-16 20:29 ` [Bug fortran/40851] [4.3] " burnus at gcc dot gnu dot org
@ 2009-08-16 20:52 ` steven at gcc dot gnu dot org
  2009-08-16 21:37 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-08-16 20:52 UTC (permalink / raw)
  To: gcc-bugs



-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.6


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (8 preceding siblings ...)
  2009-08-16 20:52 ` [Bug fortran/40851] [4.3/4.4/4.5] " steven at gcc dot gnu dot org
@ 2009-08-16 21:37 ` rguenth at gcc dot gnu dot org
  2009-08-23 11:09 ` mikpe at it dot uu dot se
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-16 21:37 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.6                       |4.3.5


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (9 preceding siblings ...)
  2009-08-16 21:37 ` rguenth at gcc dot gnu dot org
@ 2009-08-23 11:09 ` mikpe at it dot uu dot se
  2009-08-23 16:01 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu dot se @ 2009-08-23 11:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mikpe at it dot uu dot se  2009-08-23 11:09 -------
(In reply to comment #7)
> FIXED on the 4.3 branch -> Close.

Minor nit: the commit to 4.3 didn't add the test case.


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (10 preceding siblings ...)
  2009-08-23 11:09 ` mikpe at it dot uu dot se
@ 2009-08-23 16:01 ` burnus at gcc dot gnu dot org
  2009-08-23 16:02 ` burnus at gcc dot gnu dot org
  2009-08-23 16:53 ` mikpe at it dot uu dot se
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-08-23 16:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from burnus at gcc dot gnu dot org  2009-08-23 16:01 -------
Subject: Bug 40851

Author: burnus
Date: Sun Aug 23 16:01:11 2009
New Revision: 151034

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151034
Log:
2009-08-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40851
        * gfortran.dg/derived_init_3.f90: New test.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/derived_init_3.f90
Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (11 preceding siblings ...)
  2009-08-23 16:01 ` burnus at gcc dot gnu dot org
@ 2009-08-23 16:02 ` burnus at gcc dot gnu dot org
  2009-08-23 16:53 ` mikpe at it dot uu dot se
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-08-23 16:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from burnus at gcc dot gnu dot org  2009-08-23 16:02 -------
(In reply to comment #8)
> (In reply to comment #7)
> > FIXED on the 4.3 branch -> Close.
> Minor nit: the commit to 4.3 didn't add the test case.

I forgot to do a "svn add" - and I forgot to do a "svn status" to find such
problems. It is not corrected.


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/40851] [4.3/4.4/4.5] problem with deallocation of pointers
  2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
                   ` (12 preceding siblings ...)
  2009-08-23 16:02 ` burnus at gcc dot gnu dot org
@ 2009-08-23 16:53 ` mikpe at it dot uu dot se
  13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu dot se @ 2009-08-23 16:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from mikpe at it dot uu dot se  2009-08-23 16:53 -------
(In reply to comment #10)
> (In reply to comment #8)
> > (In reply to comment #7)
> > > FIXED on the 4.3 branch -> Close.
> > Minor nit: the commit to 4.3 didn't add the test case.
> 
> I forgot to do a "svn add" - and I forgot to do a "svn status" to find such
> problems. It is not corrected.

Thanks


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-08-23 16:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-24 20:03 [Bug fortran/40851] New: problem with deallocation of pointers juergen dot reuter at desy dot de
2009-07-24 20:05 ` [Bug fortran/40851] " juergen dot reuter at desy dot de
2009-07-25  6:56 ` burnus at gcc dot gnu dot org
2009-07-25 19:14 ` burnus at gcc dot gnu dot org
2009-07-27  9:32 ` burnus at gcc dot gnu dot org
2009-07-27  9:33 ` [Bug fortran/40851] [4.3/4.4] " burnus at gcc dot gnu dot org
2009-07-29  9:35 ` burnus at gcc dot gnu dot org
2009-08-16 20:29 ` [Bug fortran/40851] [4.3/4.4/4.5] " burnus at gcc dot gnu dot org
2009-08-16 20:29 ` [Bug fortran/40851] [4.3] " burnus at gcc dot gnu dot org
2009-08-16 20:52 ` [Bug fortran/40851] [4.3/4.4/4.5] " steven at gcc dot gnu dot org
2009-08-16 21:37 ` rguenth at gcc dot gnu dot org
2009-08-23 11:09 ` mikpe at it dot uu dot se
2009-08-23 16:01 ` burnus at gcc dot gnu dot org
2009-08-23 16:02 ` burnus at gcc dot gnu dot org
2009-08-23 16:53 ` mikpe at it dot uu dot se

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).