From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DFE983858C39; Fri, 3 Nov 2023 15:23:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFE983858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699025013; bh=ulnAjMv8kk31Ez+uL50b9QE3tzXIUvBYjtWQ+ECNbSA=; h=From:To:Subject:Date:From; b=brXbJ8RKa3EQDDlUKw3PGbAD+tN9iOY92SxDp+m0goGMO/jqK8RNg/kVZCwJY2B2x Ahv4vHbzMOZcXa9AKi05a0eRc/+xJ/ZRjXs5gEwE4nzQzgYywTGeUb3SOA2st+lOOp Z3ATwHohP5jIH3Jka9nxnem/lUiBKR8qxjCowpZ8= From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/112371] New: Wrong upper bound for the result of reduction intrinsics if the array is empty Date: Fri, 03 Nov 2023 15:23:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D112371 Bug ID: 112371 Summary: Wrong upper bound for the result of reduction intrinsics if the array is empty Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mikael at gcc dot gnu.org Target Milestone: --- In the following example, I expect the ubound to be (/ 3, 0, 7 /), but the printed values are (/ 0, 0, 7 /). program p implicit none call check_iparity call check_sum call check_minloc contains subroutine check_iparity integer :: a(9,3,0,7) integer :: i integer, allocatable :: r(:,:,:) i =3D 1 a =3D reshape((/ integer:: /), shape(a)) r =3D iparity(a, dim=3Di) print *, shape(r) print *, ubound(r) ! if (any(shape(r) /=3D (/ 3, 0, 7 /))) stop 11 ! if (any(ubound(r) /=3D (/ 3, 0, 7 /))) stop 13 end subroutine subroutine check_sum integer :: a(9,3,0,7) integer :: i integer, allocatable :: r(:,:,:) i =3D 1 a =3D reshape((/ integer:: /), shape(a)) r =3D sum(a, dim=3Di) print *, shape(r) print *, ubound(r) ! if (any(shape(r) /=3D (/ 3, 0, 7 /))) stop 21 ! if (any(ubound(r) /=3D (/ 3, 0, 7 /))) stop 23 end subroutine subroutine check_minloc integer :: a(9,3,0,7) integer :: i integer, allocatable :: r(:,:,:) i =3D 1 a =3D reshape((/ integer:: /), shape(a)) r =3D minloc(a, dim=3Di) print *, shape(r) print *, ubound(r) ! if (any(shape(r) /=3D (/ 3, 0, 7 /))) stop 31 ! if (any(ubound(r) /=3D (/ 3, 0, 7 /))) stop 33 end subroutine end program=