https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102599
Bug ID: 102599 Summary: Wrong simplification of inquiry parameters for complex arrays Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- Consider: program p implicit none complex, parameter :: x(2) = 1 real, parameter :: r(*) = x%re real, parameter :: i(*) = x%im print *, r, all(r == 1) ! wrong print *, i, all(i == 0) ! wrong print *, x%re, all(x%re == 1) ! OK print *, x%im, all(x%im == 0) ! OK end This prints: 1.00000000 0.00000000 T 1.00000000 0.00000000 F 1.00000000 1.00000000 T 0.00000000 0.00000000 T The first two lines should be identical to the last two. The dump-tree has: static real(kind=4) r[2] = {__complex__ (1.0e+0, 0.0), __complex__ (1.0e+0, 0.0)}; static real(kind=4) i[2] = {__complex__ (1.0e+0, 0.0), __complex__ (1.0e+0, 0.0)}; static complex(kind=4) x[2] = {__complex__ (1.0e+0, 0.0), __complex__ (1.0e+0, 0.0)}; which is nonsense for r, i. Furthermore, all(x%re == 1) and all(x%im == 0) are not simplified, but that's another story...