From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A1AF93858D3C; Wed, 21 Jun 2023 21:10:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1AF93858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687381846; bh=S54VmpZhhDCCCObgQQ+WT+B1eIuhZdzIpH/h2foCTn4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HJcz+CuesyB6HlDesscfYUKDnz3ZMJ2l/5PLVCPkMzPhqt5lOJpl6nIFbN+4focYP wJpPvpjCE7QLUztHCFR8RgjaJrbzwp0WfVqtI057UKU5dj3vKdhTnyHqXnV866LzpY Ch2fM7R7/WJfrEF6lAhQc5f9D+dTpYStftrQ5+aQ= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100650] Passing a derived-type array constructor to the reshape intrinsic gives incorrect results Date: Wed, 21 Jun 2023 21:10:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on cc everconfirmed bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100650 Paul Thomas changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-06-21 CC| |pault at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #3 from Paul Thomas --- (In reply to Damian Rouson from comment #1) > Here's a shorter reproducer: >=20 > % cat reshape-array-constructor.f90=20 > type foo_t > integer, allocatable :: bar(:) > end type >=20 > type(foo_t) foo(2,1) > integer :: i, j, n(2,2,1) =3D reshape([-1,-1,1,1], [2,2,1]) >=20 > foo =3D reshape([([(foo_t(merge(0, 1, n(:,i,j) > 0)), i=3D1,2)], j=3D1,= 1)], > [2,1]) > print *, merge(0, 1, n(:,1,1) > 0), foo(1,1)%bar > print *, merge(0, 1, n(:,2,1) > 0), foo(2,1)%bar > end > % gfortran reshape-array-constructor.f90=20 > % ./a.out > 1 1 -358465392 24440 > 0 0 -358465392 24440 > % gfortran --version > GNU Fortran (Homebrew GCC 13.1.0) 13.1.0 >=20 > Another workaround in the above example is to make n a constant array via >=20 > integer, parameter :: n(*,*,*) =3D reshape([-1,-1,1,1], [2,2,1]) I have played with this a bit. It's a complete mess. Breaking out the inner array constructor to a temporary produces the same result. I have put it on my list of TODOs. First finish associate, gather up the la= st of the select type bugs and attack PDTs. Cheers Paul=