https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122388
Bug ID: 122388
Summary: [13/14/15/16 Regression] Fortran shadow_loopvar seems
to lead to miscompilation
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
The following example:
integer (8) i, u8, step8
call test ((/ (i, i = u8, l4step8) /), u8, 0_8, step8)
contains
subroutine test (a, l, u, step)
integer (8), dimension (:) :: a
integer (8) l, u, step
do i = u, step
j = 1
end do
if (size (a) .ne. j - 1) STOP 2
end
end
Compiled with
gfortran array.f90 -O2 -o array.exe -fno-tree-loop-vectorize
fails but
gfortran array.f90 -O2 -o array.exe -fno-tree-loop-vectorize -fno-tree-dce
or
gfortran array.f90 -O1 -o array.exe -fno-tree-loop-vectorize
works.
The difference starts at the front-end where compared with -O1 at -O2 fortrans
trans_array transform seems to kick in.
I've been able to reproduce this on every GCC from 6 to 16 and can reproduce it
on latest HEAD on AArch64 and x86_64.