https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114023
Bug ID: 114023
Summary: complex part%ref of complex named constant array
cannot be used in an initialization expression.
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargl at gcc dot gnu.org
Target Milestone: ---
Found with the Fujitsu testsuite. The original code led to
an ICE, but the modified version here compiles and executes.
It is however wrong-code as the testcase stops at STOP 1.
!
! https://github.com/fujitsu/compiler-test-suite
! Modified from Fortran/0093/0093_0025.f90
!
complex(kind=8), parameter :: cmp1(3) = [(1,2),(3,4),(5,6)]
complex(kind=16), parameter :: cmp2(3) = [(1,2),(3,4),(5,6)]
real(8) :: rr(3) = cmp1%re
real(8) :: qq(3) = cmp1%im
real(16) :: rr2(3) = cmp2%re
real(16) :: qq2(3) = cmp2%im
if (any(int(rr) /= [1,3,5])) stop 1
if (any(int(qq) /= [2,4,6])) stop 2
if (any(int(rr2) /= [1,3,5])) stop 3
if (any(int(qq2) /= [2,4,6])) stop 4
end
Modifying the code to output rr shows
% gfcx -o z 0093/0093_0036.f90 && ./z
1.0000000000000000 2.0000000000000000 0.0000000000000000