public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52102] New: [OOP] Wrong result with ALLOCATE w/ SOURCE= and nonpoly. array constructor source-expr
@ 2012-02-03  7:49 burnus at gcc dot gnu.org
  2012-02-03  8:22 ` [Bug fortran/52102] [OOP] Wrong result with ALLOCATE of CLASS components with array constructor SOURCE-expr burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-03  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52102
           Summary: [OOP] Wrong result with ALLOCATE w/ SOURCE= and
                    nonpoly. array constructor source-expr
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


The following program, which is an extension of
testsuite/gfortran.dg/class_48.f90 and thus PR 51972 fails to correctly set the
value via SOURCE:

  allocate (two%a(2), source=[t(4), t(6)])

Should give for two%a(1)%x and two%a(2)%x the values 4 and 6, but one gets 0 0.
If one uses not a class component but a class variable, the result is 4 0.

There is a similar PR for polymorphic sources, cf. PR 51864.


subroutine test3 ()
  type t
    integer :: x
  end type t

  type t2
    class(t), allocatable :: a(:)
  end type t2

  type(t2) :: one, two

  one = two
  if (allocated (one%a)) call abort ()

  allocate (two%a(2), source=[t(4), t(6)])
  one = two
  if (.not.allocated (one%a)) call abort ()

  print *, one%a(1)%x
  print *, one%a(6)%x
  if ((one%a(1)%x /= 4)) call abort ()
  if ((one%a(2)%x /= 6)) call abort ()

  deallocate (two%a)
  one = two
  if (allocated (one%a)) call abort ()
end subroutine test3


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

end of thread, other threads:[~2012-02-05 20:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-03  7:49 [Bug fortran/52102] New: [OOP] Wrong result with ALLOCATE w/ SOURCE= and nonpoly. array constructor source-expr burnus at gcc dot gnu.org
2012-02-03  8:22 ` [Bug fortran/52102] [OOP] Wrong result with ALLOCATE of CLASS components with array constructor SOURCE-expr burnus at gcc dot gnu.org
2012-02-03 13:22 ` burnus at gcc dot gnu.org
2012-02-03 13:38 ` burnus at gcc dot gnu.org
2012-02-05 19:56 ` pault at gcc dot gnu.org
2012-02-05 20:06 ` pault at gcc dot gnu.org

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