From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41405 invoked by alias); 24 Feb 2018 00:45:51 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 33199 invoked by uid 89); 24 Feb 2018 00:45:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=benson, H*UA:KMail, Benson, site X-HELO: mail-pg0-f52.google.com Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 24 Feb 2018 00:45:47 +0000 Received: by mail-pg0-f52.google.com with SMTP id f6so3975677pgs.10 for ; Fri, 23 Feb 2018 16:45:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding; bh=L4OaOozU9Z/DoQmqqrWom7lj6kh3vnEGyHJzv2wbXb0=; b=DfBVDIY1GVVMcgTZeA+NYTxfSLq93+mXDT3SOQwFwRQTWmCdDDncnPQp9lg/Tu/0G1 SP+okje5I9EdA8ylqdMeDCbACEYaPWxDZD3Z0W2c46dvSK1754QTS6jsTy72Lxbdg5xe 5JQv3omyPKqnSTMLuWBI1rWQBorRxKGl+NXhZJdsV5ty2LuIFZfA8pRPllyMSA1RhXhX WEUJyWGchIs00kiNhDMEBsCPFVZEhtA+DQFW9R6oGheWSMlanQueauC7ZvVEkAJsGp/w I4PWLkkygK4yUvGDEkeMD0SVVVrts3sDCvcwJcqMFdytvmDTQRZfG2lj9dVrd+xjxXee ZZHw== X-Gm-Message-State: APf1xPArHi7FJ+zsaqXCSc6k0di153rO34wJQ6aY7g3teIprvhr9eT1m mtNz1DSgaxaDEID2gHB/JSIfJMCG X-Google-Smtp-Source: AH8x22631PlPcueFe7AFolCerr/ayjznxJVeRga6tIN2EUt+yDnvVc5VtRJnr8DGF9FzJkRYdUrRxg== X-Received: by 10.101.66.1 with SMTP id c1mr2767866pgq.137.1519433145155; Fri, 23 Feb 2018 16:45:45 -0800 (PST) Received: from andrew-precision-3520.localnet (pool-239.obs.carnegiescience.edu. [192.91.178.239]) by smtp.gmail.com with ESMTPSA id v8sm6215753pff.38.2018.02.23.16.45.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 16:45:44 -0800 (PST) From: Andrew Benson To: gfortran Subject: Array of derived type elements incorrectly accessed in function Date: Sat, 24 Feb 2018 00:45:00 -0000 Message-ID: <126623536.nj9Msx1Vf3@andrew-precision-3520> User-Agent: KMail/5.2.3 (Linux/4.4.0-116-generic; KDE/5.36.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00169.txt.bz2 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