public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Array of derived type elements incorrectly accessed in function
@ 2018-02-24  0:45 Andrew Benson
  0 siblings, 0 replies; only message in thread
From: Andrew Benson @ 2018-02-24  0:45 UTC (permalink / raw)
  To: gfortran

I created PR84538 for the following bug:

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


The following code results in incorrect behavior with gfortran 8.0.1 
(r257956):

module bugMod
  public
  type :: t
     integer :: i
  end type t
  type, extends(t) :: te
     integer :: j
  end type te
contains
  subroutine check(n)
    implicit none
    class(t), intent(inout), dimension(:) :: n
    write (0,*) "FROM MODULE  ",n%i
    return
  end subroutine check
end module bugMod

program bug
  use bugMod
  class(t), allocatable, dimension(:) :: n
  allocate(te :: n(2))
  n(1:2)%i=[8,3]
  write (0,*) "FROM PROGRAM ",n%i
  call check(n)
end program bug

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/nfs/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-pc-
linux-gnu/8.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/nfs/home/abenson/Galacticus/Tools --
enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 8.0.1 20180223 (experimental) (GCC) 

$ gfortran bug.F90
$ a.out 
 FROM PROGRAM            8           3
 FROM MODULE             8           0

I would expect the output to be the same from the module subroutine as from 
the main program.

-- 

* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html

* Galacticus: http://sites.google.com/site/galacticusmodel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-24  0:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-24  0:45 Array of derived type elements incorrectly accessed in function Andrew Benson

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