[Bug fortran/41937] New: Error in allocating derived type allocatable components

View: New views
6 Messages — Rating Filter:   Alert me  

[Bug fortran/41937] New: Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When trying to compile the sample file, gfortran (I'm referring to the revision
r153847) chokes over allocating an allocatable array whose length depends on an
integer derived type in the same abstract type.
gfortran -c cuba_types_bug.f03
cuba_types_bug.f03:16.28:

      allocate(this%integral(this%dim_f))
                            1
Error: 'this' must not appear in the array specification at (1) in the same
ALLOCATE statement where it is itself allocated

I think the code is OK according to the F2003 specification.

******
The test code is:
module cuba_types_module
  implicit none

  type, abstract :: cuba_abstract_type
     private
     integer :: dim_f = 1
     real, dimension(:), allocatable :: integral
   contains
     procedure :: alloc_dim_f => cuba_abstract_alloc_dim_f
  end type cuba_abstract_type

  contains

    subroutine cuba_abstract_alloc_dim_f(this)
      class(cuba_abstract_type) :: this
      allocate(this%integral(this%dim_f))
    end subroutine cuba_abstract_alloc_dim_f

end module cuba_types_module


--
           Summary: Error in allocating derived type allocatable components
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reuter at physik dot uni-freiburg dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


[Bug fortran/41937] Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #1 from reuter at physik dot uni-freiburg dot de  2009-11-04 12:39 -------
Created an attachment (id=18963)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18963&action=view)
sample code for the bug case


--


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


[Bug fortran/41937] [OOP] Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #2 from burnus at gcc dot gnu dot org  2009-11-04 14:33 -------
Confirmed. The following - untested - should fix it. I am not sure, when I have
time to submit it. Janus, if you want to do the honour, go ahead.

Index: resolve.c
===================================================================
--- resolve.c   (revision 153896)
+++ resolve.c   (working copy)
@@ -6198,7 +6198,8 @@ check_symbols:
          sym = a->expr->symtree->n.sym;

          /* TODO - check derived type components.  */
-         if (sym->ts.type == BT_DERIVED)
+         if (sym->ts.type == BT_DERIVED
+             || sym->ts.type == BT_CLASS)
            continue;

          if ((ar->start[i] != NULL


--

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-04 14:33:01
               date|                            |
            Summary|Error in allocating derived |[OOP] Error in allocating
                   |type allocatable components |derived type allocatable
                   |                            |components


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


[Bug fortran/41937] [OOP] Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #3 from janus at gcc dot gnu dot org  2009-11-04 16:33 -------
(In reply to comment #2)
> Janus, if you want to do the honour, go ahead.

Yes, I can do it.


--

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-11-04 14:33:01         |2009-11-04 16:33:35
               date|                            |


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


[Bug fortran/41937] [OOP] Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #4 from janus at gcc dot gnu dot org  2009-11-04 19:41 -------
Subject: Bug 41937

Author: janus
Date: Wed Nov  4 19:41:07 2009
New Revision: 153911

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153911
Log:
2009-11-04  Tobias Burnus <burnus@...>
            Janus Weil  <janus@...>

        PR fortran/41556
        PR fortran/41937
        * interface.c (gfc_check_operator_interface): Handle CLASS arguments.
        * resolve.c (resolve_allocate_expr): Handle allocatable components of
        CLASS variables.


2009-11-04  Janus Weil  <janus@...>

        PR fortran/41556
        PR fortran/41937
        * gfortran.dg/class_11.f03: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_11.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


--


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


[Bug fortran/41937] [OOP] Error in allocating derived type allocatable components

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #5 from janus at gcc dot gnu dot org  2009-11-04 19:46 -------
Fixed with r153911. Closing.


--

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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