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/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work


Currently, the size needed for allocation is not taken into account with CLASS. 

The example below should print
  42 -4.0
but prints
  512   0.0000000

Expected:

a) The warning
"Warning: Dynamic size allocation at (1) not supported yet, using size of
declared type"
is turned into an error as interim measure
(cf. ifort: "Feature not yet implemented: SOURCE=polymorphic_expression")

b) The dynamic-size implementation is implemented.


Example:

type t
end type t
type,extends(t) :: t2
  integer :: i = 54
  real :: r = 384.02
end type t2

class(t), allocatable :: m1, m2
allocate(t2 :: m2)
select type(m2)
 type is (t2)
   m2%i = 42
   m2%r = -4.0
end select
allocate(m1, source=m2)
select type(m1)
 type is (t2)
 print *, m1%i, m1%r ! shall print "42  -4.0"
end select
end


-- 
           Summary: [OOP] Allocation of a CLASS with SOURCE=<class> does not
                    work
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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