gcc/libgfortran/m4
Jakub Jelinek 748a7bc462 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.
2025-05-13 14:25:38 +02:00
..
all.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
any.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
bessel.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
count.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
cshift0.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
cshift1.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
cshift1a.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
eoshift1.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
eoshift3.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
findloc0.m4
findloc0s.m4
findloc1.m4
findloc1s.m4
findloc2s.m4
head.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
iall.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
iany.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
ifindloc0.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
ifindloc1.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
ifindloc2.m4 libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196] 2025-05-13 14:25:38 +02:00
iforeach-s.m4
iforeach-s2.m4
iforeach.m4
ifunc.m4
ifunction-s.m4 libfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191] 2025-05-13 14:25:08 +02:00
ifunction-s2.m4 libgfortran: Remove empty array descriptor first dimension overwrite [PR112371] 2023-11-08 12:32:21 +01:00
ifunction.m4 Implement SUM and PRODUCT for unsigned. 2024-09-24 21:59:10 +02:00
ifunction_logical.m4 libgfortran: Remove empty array descriptor first dimension overwrite [PR112371] 2023-11-08 12:32:21 +01:00
in_pack.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
in_unpack.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
iparity.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
iparm.m4 libfortran: Fix up maxval/maxloc for UNSIGNED [PR120158] 2025-05-08 09:36:30 +02:00
matmul.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
matmul_internal.m4 Implement MATMUL and DOT_PRODUCT for unsigned. 2024-09-24 21:51:42 +02:00
matmulavx128.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
matmull.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxloc0.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxloc0s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxloc1.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxloc1s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxloc2s.m4 libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191] 2025-05-13 14:24:43 +02:00
maxval.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxval0s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
maxval1s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minloc0.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minloc0s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minloc1.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minloc1s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minloc2s.m4 libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191] 2025-05-13 14:24:43 +02:00
minval.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minval0s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
minval1s.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
misc_specifics.m4
mtype.m4
norm2.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
pack.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
parity.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
pow.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
powu.m4 Add modular exponentiation for UNSIGNED. 2025-02-04 08:56:19 +01:00
product.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
reshape.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
shape.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
specific.m4
specific2.m4
spread.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
sum.m4 Update copyright years. 2025-01-02 11:59:57 +01:00
types.m4
unpack.m4 Update copyright years. 2025-01-02 11:59:57 +01:00