gcc/libgfortran/m4
Jakub Jelinek b1fcb18faf libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]
As mentioned in the PR, _gfortran_{,m,s}findloc2_s{1,4} iterate too many
times in the back case if nothing is found.
For !back, the loops are for (i = 1; i <= extent; i++) so i is in the
body [1, extent] if nothing is found, but for back it is
for (i = extent; i >= 0; i--) so i is in the body [0, extent] and compares
one element before the start of the array.
Note, findloc1_s{1,4} uses
          for (n = len; n > 0; n--, src -= delta * len_array)
for the back loop and
          for (n = 1; n <= len; n++, src += delta * len_array)
for !back.  This patch fixes that.
The testcase fails under valgrind without the libgfortran changes and
succeeds with those.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR libfortran/120196
	* m4/ifindloc2.m4 (header1, header2): For back use i > 0 rather than
	i >= 0 as for condition.
	* generated/findloc2_s1.c: Regenerate.
	* generated/findloc2_s4.c: Regenerate.

	* gfortran.dg/pr120196.f90: New test.

(cherry picked from commit 748a7bc462)
2025-05-23 13:33:12 +02:00
..
all.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
any.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
bessel.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
count.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
cshift0.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
cshift1.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
cshift1a.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
eoshift1.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
eoshift3.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
findloc0.m4
findloc0s.m4
findloc1.m4
findloc1s.m4
findloc2s.m4
head.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
iall.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
iany.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
ifindloc0.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
ifindloc1.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
ifindloc2.m4 libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196] 2025-05-23 13:33:12 +02:00
iforeach-s.m4
iforeach-s2.m4
iforeach.m4
ifunc.m4 Prepare library for REAL(KIND=17). 2022-01-11 23:39:54 +01:00
ifunction-s.m4 libfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191] 2025-05-23 13:32:38 +02:00
ifunction-s2.m4
ifunction.m4
ifunction_logical.m4
in_pack.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
in_unpack.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
iparity.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
iparm.m4
matmul.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
matmul_internal.m4
matmulavx128.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
matmull.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxloc0.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxloc0s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxloc1.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxloc1s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxloc2s.m4 libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191] 2025-05-23 13:30:56 +02:00
maxval.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxval0s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
maxval1s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minloc0.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minloc0s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minloc1.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minloc1s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minloc2s.m4 libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191] 2025-05-23 13:30:56 +02:00
minval.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minval0s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
minval1s.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
misc_specifics.m4
mtype.m4 fortran, libgfortran: Avoid using libquadmath for glibc 2.26+ 2022-06-28 13:14:45 +02:00
norm2.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
pack.m4 Fortran: Eliminate nuisance warnings by initializing. 2023-02-27 18:02:59 -08:00
parity.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
pow.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
product.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
reshape.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
shape.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
specific.m4 Make sure the Fortran specifics have real(kind=16). 2022-01-11 23:49:31 +01:00
specific2.m4 Make sure the Fortran specifics have real(kind=16). 2022-01-11 23:49:31 +01:00
spread.m4 Fortran: Eliminate nuisance warnings by initializing. 2023-02-27 18:02:59 -08:00
sum.m4 Update copyright years. 2023-01-16 11:52:17 +01:00
types.m4
unpack.m4 Update copyright years. 2023-01-16 11:52:17 +01:00