https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116196
Bug ID: 116196
Summary: Missing temporary with WHERE and aliasing TARGET array
references
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: ---
The following example outputs:
1 1 2 3 5
while I think it should output:
1 1 2 4 5
I found it looking for an example exercising gfc_check_dependency with aliasing
arrays, after the analysis posted as followup to Jakub's recent pasto fix:
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/658971.html
MODULE m
IMPLICIT NONE
INTEGER, TARGET :: arr(5)
END MODULE m
PROGRAM main
USE m
IMPLICIT NONE
arr = (/ 1, 2, 3, 4, 5 /)
CALL bar(arr)
PRINT *, arr
IF (ANY(arr /= (/ 1, 1, 2, 4, 5 /))) STOP 1
CONTAINS
SUBROUTINE bar(x)
INTEGER, TARGET :: x(:)
WHERE (arr(1:4) < 3) x(2:5) = x(2:5) - 1
END SUBROUTINE bar
END PROGRAM main