public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/65359] New: [OOP] undefined output with array and inheritance
@ 2015-03-09 10:01 tkoenig at gcc dot gnu.org
  2015-03-13 14:14 ` [Bug fortran/65359] " dominiq at lps dot ens.fr
  0 siblings, 1 reply; 2+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-03-09 10:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65359

            Bug ID: 65359
           Summary: [OOP] undefined output with array and inheritance
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org

Originally from
http://stackoverflow.com/questions/28933061/using-1n-with-inherited-classes-works-weirdly-in-gfortran
:

module try_mod

implicit none

type, public :: Inner_t
  integer :: i
  real :: r
end type Inner_t

type, public, extends(Inner_t) :: InnerSpec_t
  integer :: j
end type InnerSpec_t

type, public :: Outer_t
  integer :: nelem
  class( Inner_t ), allocatable, dimension(:) :: elem

contains
  procedure :: init => initOuter

end type Outer_t


contains

 subroutine initOuter(this)
  class(Outer_t), intent(inout) :: this
  integer :: i, suma, k

  this%nelem = 4

  allocate( InnerSpec_t :: this%elem(1:this%nelem) )


  this%elem(1:2)%i = -100
  this%elem(3:4)%i = -200


  print*, '1st: ', this%elem(1:this%nelem)%i
  print*, '2nd: ', this%elem(1)%i, this%elem(2)%i, this%elem(3)%i,
this%elem(4)%i

  this%elem(1)%i = 91 
  this%elem(2)%i = 92 
  this%elem(3)%i = 93
  this%elem(4)%i = 94 
  print*,'3rd: ', this%elem(1:4)%i
  print*,'4th: ', this%elem(1)%i, this%elem(2)%i, this%elem(3)%i,
this%elem(4)%i



end subroutine initOuter

end module try_mod 

program adgo
  use try_mod

implicit none

  type( Outer_t ) :: outer

  call outer%init()
end program

... has some undefined output (also according to valgrind).


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

* [Bug fortran/65359] [OOP] undefined output with array and inheritance
  2015-03-09 10:01 [Bug fortran/65359] New: [OOP] undefined output with array and inheritance tkoenig at gcc dot gnu.org
@ 2015-03-13 14:14 ` dominiq at lps dot ens.fr
  0 siblings, 0 replies; 2+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-03-13 14:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65359

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-03-13
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed on 4.8.4, 4.9.2, and trunk (5.0). Note that the test compiled with
4.8.4 fails with

a.out(3185,0x7fff7d157300) malloc: *** error for object 0x7fd4a9405aa0:
incorrect checksum for freed object - object was probably modified after being
freed.
*** set a breakpoint in malloc_error_break to debug


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

end of thread, other threads:[~2015-03-13 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 10:01 [Bug fortran/65359] New: [OOP] undefined output with array and inheritance tkoenig at gcc dot gnu.org
2015-03-13 14:14 ` [Bug fortran/65359] " dominiq at lps dot ens.fr

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